Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kevyeung

macrumors newbie
Jan 17, 2004
2
0
Originally posted by NuPowerbook
I know, but you said it isn't a bug, when it clearly is. I was just explaining why it is a bug.

Please enlighten. When the problem is not found in a 3rd party calculator, does it mean it is not affected OR the problem only confines to the system acessory-calculator ?
 

crash_harddrive

macrumors newbie
Jan 17, 2004
3
0
Troy. Ohio
I'm not sure who said a third party calc wasn't affected, I tried two freeware calcs and both duplicated the problem. This isn't a major problem for me but it is a nagging annoyance. I use the calculator mostly for financial purposes so setting the precision to "2" would work for that but all that accomplishes is hiding the problem. The next time I need to use more than two decimal places I'm going to have a hard time trusting my results. So now it seems that there are two things Windows excels at - solitaire and an accurate calculator. Guess I'll keep my 486DX awhile longer.
 

stcanard

macrumors 65816
Oct 19, 2003
1,485
0
Vancouver
Originally posted by crash_harddrive
The next time I need to use more than two decimal places I'm going to have a hard time trusting my results. So now it seems that there are two things Windows excels at - solitaire and an accurate calculator. Guess I'll keep my 486DX awhile longer.

Okay, go back and read this thread again.

There is no problem with the accuracy or correctness of the results.

This is a perfectly good result, based on binary arithmetic, which has the side effect that some fractions that terminate in decimal do not terminate in binary.

Go ask your decimal calculator what 7 / 9 is. Are you really concerned that you are only getting the results to 10 significant digits? How about pi ^2?

If you truly have a need to work accurately to 12 significant digits, go get yourself a library that does arbitrary precision decimal math.
 

Nevsan

macrumors newbie
Jan 17, 2004
3
0
I've been programming for awhile and this is a little surprising to me, yet perfectly understandable. Of course it's never been a problem for me since I've pretty much stuck to game programming, but that's cool.
 

crash_harddrive

macrumors newbie
Jan 17, 2004
3
0
Troy. Ohio
Originally posted by stcanard
Okay, go back and read this thread again.

There is no problem with the accuracy or correctness of the results.

This is a perfectly good result, based on binary arithmetic, which has the side effect that some fractions that terminate in decimal do not terminate in binary.

Go ask your decimal calculator what 7 / 9 is. Are you really concerned that you are only getting the results to 10 significant digits? How about pi ^2?

If you truly have a need to work accurately to 12 significant digits, go get yourself a library that does arbitrary precision decimal math.

"No problem with the accuracy or correctness of the results"?
Accurate -
1 : free from error especially as the result of care "an accurate diagnosis"
2 : conforming exactly to truth or to a standard : exact "providing accurate color"
3 : able to give an accurate result "an accurate gauge"
Correct -
1 : conforming to an approved or conventional standard
2 : conforming to or agreeing with fact, logic, or known truth
3 : conforming to a set figure "enclosed the correct return postage"
(Courtesy of Encyclopedia Britannica)
My point here is that this program is NOT accurate and I'm disappointed that Apple refuses to even acknowledge the problem, let alone clean up their act. I consider Apple products to be some of the best on the market but something like this is another black eye just like the recent "white spot" issue with PowerBooks. Apple has a history of refusing to admit mistakes , which is a major slam in the credibility department.
 

ElectricSheep

macrumors 6502
Feb 18, 2004
498
4
Wilmington, DE
Okay, this is how floating point numbers work, on every single computer in existance. This is the IEEE standard for binary floating point numbers. The format is thus:

Single Format (standard float)
Code:
|s| exp (8) | mantissa (23) |

The 's' is a single bit indicating if the number is positive or negative. The 'exp' is an 8 bit biased exponent. By biased, I mean that whatever numeric representation is in 'exp', the value used in calcuations is going to be exp-127 (for normalized mantissa). The mantissa is the factional part of the exponential, with an implied leading '1' for normalized floats.

So, the number is:

(-1 * s) * (1.mantissa * 2^(exp-127))

Its pretty much like scientific notation.

Floating points, however, have a real hard time dealing with numbers like 92.79. Sure, I can easily represent 92 in binary. Its just 1011100. Nice and exact. The true problem lies in the question: "How do you represent 0.79 in binary?" This is more difficult. The solution in the IEEE specification for floating point numbers is to approximate the decimal fraction with a binary fraction. What's a binary fraction? Its a binary number where each decimal places represents another negative power of two. So, the binary fraction:

0.11001

Is the same as

(1/2) + (1/4) + (1/32)

Trouble is that decimal values like 0.79 require a veritably endless binary fraction to represent. We only have 23 bits in the mantissa to work with. Less, if you consider that the mantissa is normalized, and it contains the representation for 92 as well. So, the best that can be done is to find a close approximation. In the case of 92.79, its floating point representation is:

11000010101110011001010001111011

Where:

1 is the sign bit
10000101 is the exponent (remember, this is biased by 127)
(1.)01110011001010001111011 is the mantissa. The (1.) is implied here.

When we de-bias the exponent, we are left with a value of 6, so we have to shift the mantissa six places to the left to get the represented value:

1.01110011001010001111011 -> 1011100.11001010001111011

So what decimal value does 11001010001111011 represent? Do the math:

(1/2)+(1/4)+(1/32)+(1/128)+(1/2048)+(1/4096)+(1/8192)+(1/16384)+(1/65536)+(1/131072) = 0.7900009155273438

That's not bad, and good enough if all you need is 5 decimal places of precision. But errors like this can compound through time, so if you are working on real mission-critical calculations you can either use longer floating point representations, or implement and arbitrary precision software solution. These libraries are pretty easy to find, and writing one isn't terribly hard. We've all learned the basic algorithms for adding, subtracting, multiplying, and dividing arbitrarily sized decimal numbers: all you have to do is translate that into C or your favorite language.

Calculator isn't advertised as a mission critical arbitrary decimal precision computational tool, nor do I really expect it to implement arbitrary precision libraries.
 

cpjakes

macrumors 6502
Aug 15, 2003
377
5
Buffalo, NY
Now how about this problem with Calculator - updating the currency exchange rates. Anyone tried this lately and had a crash? Mine does, on a TiBook 550 with 10.3.3.

I was only trying to figure out what Rosie Reid was worth in USD... :)
 

simX

macrumors 6502a
May 28, 2002
765
4
Bay Area, CA
cpjakes said:
Now how about this problem with Calculator - updating the currency exchange rates. Anyone tried this lately and had a crash? Mine does, on a TiBook 550 with 10.3.3.

I was only trying to figure out what Rosie Reid was worth in USD... :)

This doesn't crash either of my 10.3.3 running computers (I've tested it on a original bondi blue iMac and a 600 MHz G3 iBook).
 

cpjakes

macrumors 6502
Aug 15, 2003
377
5
Buffalo, NY
simX said:
This doesn't crash either of my 10.3.3 running computers (I've tested it on a original bondi blue iMac and a 600 MHz G3 iBook).

Well after a trash of the Calculator prefs AND the financial rate prefs AND a restart, all seems to be fine. Who knows how that got jacked up...
 

Zaty

macrumors 65816
Mar 14, 2004
1,215
2
Switzerland
To get back to the original problem, I just happened to play around with KoalaCalc, it does the math correctly while calculator still displays the incorrect result on the tape. But I reinstalled calculator from the recovery DVD because it wouldn't update the currency conversion rates anymore. So I'm still running version 3.1 (v3.1). Could anyone please check if Apple has updated the calculator at all and if so, have they fixed this problem?

Thanks!

If your're intersted in a freeware calcualar, the above mentioned KoalaCalc is worth trying. It can be found here: http://www.macropodsoftware.com/koalacalc/index.html
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
Zaty said:
So I'm still running version 3.1 (v3.1). Could anyone please check if Apple has updated the calculator at all and if so, have they fixed this problem?
That's still the current Panther calculator, and it still uses floating point arithmetic.
 

Zaty

macrumors 65816
Mar 14, 2004
1,215
2
Switzerland
iMeowbot said:
That's still the current Panther calculator, and it still uses floating point arithmetic.

Thanks for your assistance! I guess Apple won't change the current calculator app, as Tiger is said to ship with a completely different and more powerful app.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.