Article View: borland.public.jbuilder.java.language
Article #16506Re: Math calculations
From: Richard Wilkman
Date: Wed, 17 Feb 1999 00:00
Date: Wed, 17 Feb 1999 00:00
42 lines
1915 bytes
1915 bytes
Tor: An even better way to represent currency is with two integers. One for the left side of the decimal and one for the right side of the decimal. This lets you handle presicion at the level you need. It also lets you access the full range of int for whole number values. Not as much a problem in Java as it was in C, I'll admit. (Sorry, escaped business app programmer.) <g> -Rich Tor Iver Wilhelmsen wrote: > > "Kerry Helmer" <khelmer@parlorcity.com> writes: > > >This returns 0.9899999999999949 instead of .99 Can someone help explain to > >me what I'm doing wrong? > > You're not, but the IEEE floating point standard has problems > expressing some numbers. > > > Does anybody have some rules to follow that would help me when performing > > math operations? > > Use integers for currency. (that is, represent e.g. $1.69 with the > number 169). -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 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:
<36CAE361.B36E0DAC@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7acd6l$6vc20@forums.borland.com> <usoc5whqu.fsf@sds.no>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,587049a5d7e832c X-Google-Attributes: gidf74b3,public From: Richard Wilkman <rwilkman@inprise.com> Subject: Re: Math calculations Date: 1999/02/17 Message-ID: <36CAE361.B36E0DAC@inprise.com> X-Deja-AN: 445353223 Content-Transfer-Encoding: 7bit References: <7acd6l$6vc20@forums.borland.com> <usoc5whqu.fsf@sds.no> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language