Article View: borland.public.jbuilder.java.language
Article #16332Re: 0.3-0.2=0.0999999999998?
From: Pyropunk
Date: Thu, 11 Mar 1999 00:00
Date: Thu, 11 Mar 1999 00:00
16 lines
1454 bytes
1454 bytes
Unfortunately, some of us have to read MONEY vars out of a DB. If the DB stures MONEY as floats, then you need to convert from a float to an int. And casting (as most of us know) truncates instead of rounding. This can cause some very strange behaviour. All of a sudden (56732.00 * 100) = 5673199. Frans van Duinen wrote: > > The answer is: dont use float or doubles for money amounts. Use an > integer type (e.g. long or string) and carry no more decimal places than > you show on output. > --------------------------------------- pyropunk@usa.net ---------------------------------------
Technical Details
Message-ID:
<36E76691.570E60A8@usa.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7blg56$2pl$1@zonnetje.NL.net> <7c3t96$tj8$1@nnrp1.dejanews.com> <36e65000.9658117@news.uni-erlangen.de> <36E6A482.5C59162F@myna.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5d71,3b89176b465afef X-Google-Attributes: gidf5d71,public X-Google-Thread: 10a146,3b89176b465afef X-Google-Attributes: gid10a146,public X-Google-Thread: f74b3,3b89176b465afef X-Google-Attributes: gidf74b3,public From: Pyropunk <pyropunk@usa.net> Subject: Re: 0.3-0.2=0.0999999999998? Date: 1999/03/11 Message-ID: <36E76691.570E60A8@usa.net> X-Deja-AN: 453700118 Content-Transfer-Encoding: 7bit References: <7blg56$2pl$1@zonnetje.NL.net> <7c3t96$tj8$1@nnrp1.dejanews.com> <36e65000.9658117@news.uni-erlangen.de> <36E6A482.5C59162F@myna.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 11 Mar 1999 08:45:24 +0200, 196.28.207.2 MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language,comp.lang.java,comp.lang.java.programmer