Technology Questions

Go Back   Technology Questions > Manufacturer Questions > Manufacturers > Apple > Apple Macintosh Hardware

Apple Macintosh Hardware Discuss the Apple Macintosh Hardware

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 02-06-2007, 06:08 PM
Peter McCallum
Newsgroup Contributor
 
Posts: n/a
calculator error?

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?

--
Peter McCallum
Mackay Qld AUSTRALIA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 02-06-2007, 06:08 PM
  #2 (permalink)  
Old 02-06-2007, 06:08 PM
Phil Wheeler
Newsgroup Contributor
 
Posts: n/a
Re: calculator error?

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
>


Using v. 4.0 I get the same result. But changing the precision from 12
to 16 gives a more pleasing result. And so does changing the precision
to 6. A bit odd.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 02-06-2007, 06:08 PM
Hans Aberg
Newsgroup Contributor
 
Posts: n/a
Re: calculator error?

In article <1gx8fdy.xkc4ho1cgzvfwN%p5m8.REMOVETHIS******.com. au>,
p5m8.REMOVETHIS******.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 02-06-2007, 06:08 PM
Geoff Welsh
Newsgroup Contributor
 
Posts: n/a
Re: calculator error?

Phil Wheeler wrote:
> 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
>>

>
> Using v. 4.0 I get the same result. But changing the precision from 12
> to 16 gives a more pleasing result. And so does changing the precision
> to 6. A bit odd.

I noticed that about a year ago when I first purchased OSX. (Reminded
me of using Fortan in College.)
Anyway, changing the precision to 10 worked for me.
Thanks for the tip!
GW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 02-06-2007, 06:08 PM
Randy Howard
Newsgroup Contributor
 
Posts: n/a
Re: calculator error?

In article <1gx8fdy.xkc4ho1cgzvfwN%p5m8.REMOVETHIS******.com. au>,
p5m8.REMOVETHIS******.com.au says...
> 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?


http://docs.sun.com/source/806-3568/ncg_goldberg.html

--
Randy Howard (2reply remove FOOBAR)
"I don't really care about being right you know,
I just care about success." --Steve Jobs
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculator Edward Windows XP 6 01-26-2008 02:50 AM
Calculator Confused Office User Windows XP 2 10-02-2007 01:40 AM
Calculator plwm2 Windows Vista 5 08-10-2007 03:50 PM
Calculator Dave Horne Windows Vista 2 04-19-2007 11:30 AM
calculator error? Peter McCallum Apple Macintosh Hardware 4 02-06-2007 06:10 PM


New To Technology Questions? Do You Need Help with Your Computer or Device? Do You Need Help with this site?

All times are GMT -8. The time now is 09:11 PM.


2003 - 2009 All Rights Reserved. Technology Questions

Search Engine Friendly URLs by vBSEO 3.3.0