Yikes! Calculator bug?

Status
Not open for further replies.

Untitled

Untitled
I am a computer science student and, well, frankly this bothers me...

Open up Mac OS X's calculator
do: 168740 - 19.95 to get 168720
Now get a normal calculator and find the problem (hint: answer is 168720.05)

If you do this in Mac OS X's calculator's advanced mode, it works out fine.

First off, who used the calculator to do their taxes? :eek:
Second, would someone please explain? It seems to me this could cause some grief.

Going to go check math homework...:p
 
I get that too. Also, my Calculator is really sloooowwwwww when you type in the numbers. It's really badly coded.

I think Apple's doing result = number1-number2; but not casting it to a double or float. Since the first number is an int, the result gets automatically casted to an int as well, and you loose the decimals.

Very bad coding Apple!!!
 
While Calc Thingy does exactly what you'd expect :) I must defend what the calculator is trying to do, while agreeing that it's done badly.

It's not a matter of int vs. float. The calculator thinks you only care about 6 or 7 significant digits.

10 / 3 = 3.333333

168740-19.95 = 168720.05 rounded to 168720

The exact figures are displayed properly in the paper tape. As for why it's slow for you, I don't know. But that's why I use Calc Thingy (shameless plug) Your Mileage May Vary.
 
it used to run slow for me, but for some reason it mysteriously stopped.
i use koala calc.
 
Sounds like a good project for a Cocoa newbie like me.

It's things like this that make me wonder if Apple is going downhill....
 
I think versiontracker.com may have a X48, a Hewlett Packard HP48GX emulator. This was ported from UNIX several years ago with the HP ROMs being updated periodically. Note that HP no longer makes handheld devices and that the HP ROMs are now public domain. This emulator works very well, all too well. In fact you can't enter numbers in very quickly because of the HP calculator's keyboard (you'd have to read about how it was designed to understand). Numerically this calculator is superior to Texas Instruments calculators and it uses LINPACK for linear algebra computations, therefore little or NO roundoff error.
 
Just use bc. It's a great calculator, and available on just about every flavor of unix ever invented :) Just open up a terminal window, and type "bc". To learn the syntax, "man bc".

Code:
ackack-Tue Dec 10 09:26:53$ echo 168740-19.95 | bc
168720.05
ackack-Tue Dec 10 09:27:11$ bc
168740-19.95
168720.05

Its also very very very quick :)

Brian
 
ackack-Wed Dec 11 16:57:12$ bc
scale = 10
10/3
3.3333333333
scale = 60
22/7
3.142857142857142857142857142857142857142857142857142857142857


There you go, hows that for precision? :)

Brian
 
[chimera:~] theed% bc
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
10.0/3
3
10/3.0
3
10.0/3.0
3
screw you
(standard_in) 4: parse error

I understand the power of bc, and the problem is one of rounding, but the problem is that the user has a simple need, and it's not met with a reasonable result. And the way to get the result is not particularly apparent to the average mac user. If you're a CLI type of guy, then bc should be fine for you. But I would never recommend bc to a GUI type of guy.

With all of the freeware calculators on versiontracker, and the tape output of the default calculator showing reasonably full results, bc may as well be dead for mac users.

EDited: But thanks for properly demonstrating the actual power of bc all the same, bt.
 
I understand that there are calculators that work as expected for mac os x however my point was the calculator provided by apple does not work!!
If M$ can pull off offering a calculator that does what is expected, shoulden't apple at the least be able to make a calculator worthy of comparision?! :confused:
 
the calculator is not explicit enough about what it's doing, however it is not losing precision. Further calculations with the apparently rounded value would correct themselves as the information is being simplified for display purposes but not for internal calculations. Use the paper tape option or view my screen grab in obnoxiously large pdf.

And for a good windows calculator, you should try GraphCalc. Seriously.
 

Attachments

  • calc.pdf
    47.2 KB · Views: 20
or I'll attach it here. :)

It's actually a tar.gz - I added .sit for official attachment capability. It should auto-open anyway. Let us know if that calculator works in 10.1. It could go either way.
 

Attachments

  • calc.tar.gz.sit
    67.2 KB · Views: 4
Originally posted by theed
the calculator is not explicit enough about what it's doing, however it is not losing precision. Further calculations with the apparently rounded value would correct themselves as the information is being simplified for display purposes but not for internal calculations.

Perhaps I am overreacting (As I usually do :rolleyes:),
However you would thing that Apple would at least give you a special character in the display as most calculators do if there is more data to be seen. I am sure many people have been affected by this problem which they are most likely unaware of because of the lack of a special case character.
 
That's what I meant by not being explicit enough. I am not going to argue with Apple's information hiding tendencies, they tend to keep the macintosh working environment relatively low stress. But with the calculator, they should make it explicit in even the default fully dumbed down interface that there is rounding going on.

I also think that where they decided to round was too soon. Although Mathematica seems to have the exact same default policy. In my calculator I rounded at the 12th number by default. 64 bit floating point numbers are accurate to about the 17 digit. (base 10)

Anything else I can agree with you on? :)

I agree the calculator could be better, but it's an order of magnitude better than the one they were giving away before. There was a proliferation of calculator programs before 10.2. Apple seems to have curbed the desire of every Tom Dick and Harry to make a calculator better than Apple's.
 
When I get the sine of 180, it gives me -4.102 * 10^-10. Thats a very small number, but ITS NOT 0! Sin(180)=0!

The calculator is horrible.
 
Status
Not open for further replies.
Back
Top