Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Calculator Problem

Calculator Problem
Thread Tools
Professional Poster
Join Date: Mar 2002
Status: Offline
Reply With Quote
Oct 7, 2004, 10:17 PM
 
I'm posting this here, because the Calculator is part of OSX, if I have errered, please forgive me and move to appropriate forum.

A strange thing happened when I tried to add the following two numbers in the calculator:

3721.03 + 1329.75

= 5050.780000000001

What do you get when you add thosee two numbers?

     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Oct 7, 2004, 11:38 PM
 
Originally posted by Buckaroo:
I'm posting this here, because the Calculator is part of OSX, if I have errered, please forgive me and move to appropriate forum.

A strange thing happened when I tried to add the following two numbers in the calculator:

3721.03 + 1329.75

= 5050.780000000001

What do you get when you add thosee two numbers?
I get the same thing (Mac OS X v10.3.5, Calculator v3.1). It is a floating point error. Not a big deal but it still shouldn't happen.
I also tried setting the Precision to 16 (same problem), 9 (no problem), 11 (no problem)... the default is 12 (problem). The precision is set in View --> Precision. You will get a similar error in any digital electronic calculator if you, say, take the square root of 5, then square the result, and then subtract 5 from that. You should get 0 but in Calculator.app I get 8.881784197e-16 which is a really tiny number but also not 0. This is acceptable for something like a non-integer square root value. I would not consider it acceptable for simple addition to two decimal places. A nine year old child wouldn't make the same mistake.

Incidentally this points up an interesting (to me anyhow) problem in the use of computers and calculators... people tend to think of them as being super accurate when it comes to simple arithmetic. Many people trust them implicitly. It is rare that a computer program makes such mistakes and far more common that it is user error.

For example I was tutoring a student in Physics today and he said the that cosine of 60 degrees was -0.952413, which is clearly wrong. The cosine of any angle greater than or equal to -90 degrees and less than or equal to 90 degrees can never be negative. He had the mode set to radians. Having the incorrect mode set for the units of angles is a common mistake (I make the same mistake often). One should, hopefully, be able to notice when a result is clearly wrong.

Another simple example ut MUCH harder to catch is when solving two equations in two unknowns. If the lines are nearly parallel a small rounding error in one solution can lead to a huge error in another. It becomes really difficult when solving 2+n equations in 2+n unknowns. These types of equations are sometimes called "ill conditioned equations". The trick is to be able spot these types of problems before one makes some fatal mistake in designing a bridge or an aircraft or a financial prediction. Just punching the values in to some calculator or spreadsheet and blindly using the result is not a safe strategy.
-DU-...etc...
     
Dedicated MacNNer
Join Date: Sep 2002
Status: Offline
Reply With Quote
Oct 8, 2004, 05:16 AM
 
I would not consider it acceptable for simple addition to two decimal places
You are welcome to do so, but it's not going to help you. Quite a few finite decimals have an infinite representation in binary. No finite binary computer is every going to get the above addition correct. Using quad precision arithmetic, the answer comes out as
5050.7800000000000000000000000000005
(Sun WS 9)

As you say, the art is interpreting the results you get correctly.
     
Forum Regular
Join Date: Sep 2004
Location: Earth
Status: Offline
Reply With Quote
Oct 8, 2004, 03:06 PM
 
See: "Mac OS X 10.3: Calculator Rounding Errors."

Choose a lower Precision setting from the View menu in Calculator to avoid this issue.
Good Luck!

Dr. Smoke
Author: Troubleshooting Mac OS X
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 06:49 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2