Article View: borland.public.jbuilder.java.language
Article #16375Re: 0.3-0.2=0.999999999998?
From: Roedy Green
Date: Thu, 04 Mar 1999 00:00
Date: Thu, 04 Mar 1999 00:00
24 lines
1923 bytes
1923 bytes
On Thu, 04 Mar 1999 23:57:30 +1100, Tudor Holton <tudor@alphalink.com.au> wrote: >I've never understood why we can't just represent numbers after the >decimal place as the size in reverse. e.g. 16.16 would be A:3D (or >16:61 in decimal) Mike Cowlishaw (The inventor of Rexx and NetRexx) would agree with you. He has been lobbying for floating point hardware to be redesigned to work in base 10 rather than base 2 to avoid these anomalies. People are used to .3333... + .66666 = .9999 but they don't expect 0.1 to behave the same way. I disagree. Binary arithmetic is faster and simpler. The repeaters just move to different places. You can't get rid of them. If you want absolute precision, use scaled integer arithmetic which is many times faster that floating point (e.g. integer pennies for currency, with a decorative decimal point inserted for display). For the JAVA GLOSSARY and the CMP Utilities: <http://mindprod.com> -- Roedy Green, Canadian Mind Products -30-
Technical Details
Message-ID:
<36e3c58e.73834728@news.bctel.ca>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7blg56$2pl$1@zonnetje.NL.net> <36DE833A.DFA9E627@alphalink.com.au>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: roedy@mindprod.com (Roedy Green) Subject: Re: 0.3-0.2=0.999999999998? Date: 1999/03/04 Message-ID: <36e3c58e.73834728@news.bctel.ca> X-Deja-AN: 451245319 Content-Transfer-Encoding: 7bit References: <7blg56$2pl$1@zonnetje.NL.net> <36DE833A.DFA9E627@alphalink.com.au> Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@bctel.net X-Trace: news.bctel.net 920572964 209.53.13.103 (Thu, 04 Mar 1999 10:42:44 PDT) Organization: Canadian Mind Products MIME-Version: 1.0 NNTP-Posting-Date: Thu, 04 Mar 1999 10:42:44 PDT Newsgroups: borland.public.jbuilder.java.language,comp.lang.java,comp.lang.java.programmer