Article View: comp.sys.mac
Article #48066Re: calculator error?
From: Hans Aberg
Date: Fri, 27 May 2005 11:59
Date: Fri, 27 May 2005 11:59
24 lines
1636 bytes
1636 bytes
In article <1gx8fdy.xkc4ho1cgzvfwN%p5m8.REMOVETHIS@yahoo.com.au>, p5m8.REMOVETHIS@yahoo.com.au (Peter McCallum) wrote: > When I use Calculator (v3.2.1) to do the following calculation: > 9000 - 8387.7 - 557.3 > > I get the result: > 54.999999999999 > > What gives? Most computers nowadays converts all floating point numbers into binary form, and then performs operations on those. Thus, round-off errors might occur. You can get better precision in Terminal, by searching for calculator programs: man -k calculator One such program is "bc". You can learn about it by typing "man bc". Then type: echo "9000 - 8387.7 - 557.3" | bc 55.0 Here, the answer is merely a round-off of a higher precision result. -- Hans Aberg
Technical Details
Message-ID:
<haberg-2705051359120001@c83-250-192-229.bredband.comhem.se>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newspeer2.se.telia.net!se.telia.net!masternews.telia.net.!newsc.telia.net.POSTED!not-for-mailReferences:
<1gx8fdy.xkc4ho1cgzvfwN%p5m8.REMOVETHIS@yahoo.com.au>Show Full Headers
Complete Article Headers
X-Google-Thread: 10b5e3,5f309679d98e649f X-Google-Attributes: gid10b5e3,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newspeer2.se.telia.net!se.telia.net!masternews.telia.net.!newsc.telia.net.POSTED!not-for-mail From: haberg@math.su.se (Hans Aberg) Newsgroups: comp.sys.mac,aus.computers.mac Subject: Re: calculator error? Message-ID: <haberg-2705051359120001@c83-250-192-229.bredband.comhem.se> References: <1gx8fdy.xkc4ho1cgzvfwN%p5m8.REMOVETHIS@yahoo.com.au> Organization: Mathematics User-Agent: NewsWatcher-X 2.2.3b2 Lines: 24 Date: Fri, 27 May 2005 11:59:10 GMT NNTP-Posting-Host: 83.250.192.229 X-Complaints-To: abuse@telia.com X-Trace: newsc.telia.net 1117195150 83.250.192.229 (Fri, 27 May 2005 13:59:10 CEST) NNTP-Posting-Date: Fri, 27 May 2005 13:59:10 CEST