Article View: borland.public.jbuilder.java.language
Article #18365Re: What is a BigDecimal ?
From: Richard Wilkman
Date: Thu, 02 Jul 1998 00:00
Date: Thu, 02 Jul 1998 00:00
68 lines
2595 bytes
2595 bytes
OL BigDecimal is a wrapper class in java.math. Like other data type wrapper classes (like Integer, Long, Double, etc.) you don't use it directly with numeric operators. Numeric operators expect primitive data types like int, float, double. Look at the methods associated with BigDecimal. There are things like BigDecimal.multiply(), etc. that you would use. -Rich OL wrote: > > Hello; > > I am developing some business classes. > > It was suggested to me to use the BigDecimal type to map a NUMERIC, > DECIMAL, MONEY or SMALLMONEY database type. > > I am having the following problem when using BigDecimal : > > 1. It does not seem very feasible to use common operators like '/' or > '-' when using BigDecimal. > > Exemple: > "montTvaLigne = montTvaLigne + ( montLig * ( 1 + ( tauxTva / 100)));" > generates the following error message in JBuilder 2 : > "Error 103 : method / (java.math.BigDecimal, int) not found in class > Client." > > The same exact line works fine if I change my type declaration from > BigDecimal to double. > > 2. A simple affectation like : > "cli_id = 1.0000;" > causes > "Error: (63) incompatible types; found: double, required: > java.math.BigDecimal" > but > "cli_id = new BigDecimal(1);" works. > > So, to me BigDecimal doesn't appear to be very user-friendly. > > What is it intendeed for ? > Do you use it as a solid alternative to double as was suggested to me ? > > Thanks for any clarification; > > Olivier. > Simple language question may be. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Rich Wilkman Senior Quality Assurance Engineer Borland JBuilder Team If you see something that looks like an opinion up there, it's mine and mine alone. Mail sent to me from the newsgroups won't bounce but will be ignored. If I have time, I'll respond, but you have a better chance if you confine your posts to the newsgroups =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID:
<359BF526.1A399B82@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<359BA71E.5F3D2976@compuserve.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,f6a1b28a03366ef X-Google-Attributes: gidf74b3,public From: Richard Wilkman <rwilkman@inprise.com> Subject: Re: What is a BigDecimal ? Date: 1998/07/02 Message-ID: <359BF526.1A399B82@inprise.com> X-Deja-AN: 368201827 Content-Transfer-Encoding: 7bit References: <359BA71E.5F3D2976@compuserve.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language