PDA

View Full Version : Yikes! Calculator bug?



Untitled
December 9th, 2002, 08:48 PM
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

Captain Code
December 9th, 2002, 10:30 PM
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!!!

theed
December 10th, 2002, 12:16 AM
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.

boi
December 10th, 2002, 03:17 AM
it used to run slow for me, but for some reason it mysteriously stopped.
i use koala calc.

Untitled
December 10th, 2002, 07:15 AM
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....

chemistry_geek
December 10th, 2002, 07:41 AM
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.

btoneill
December 10th, 2002, 09:28 AM
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".



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

michaelsanford
December 10th, 2002, 02:33 PM
My fav's PCalc2, way better than Apple's little pocket-jobby.

theed
December 11th, 2002, 01:47 PM
My problem with bc is that 10/3 gives you 3

theed
December 11th, 2002, 02:12 PM
same as above.

chevy
December 11th, 2002, 04:10 PM
did you try 10.0 / 3 ?

btoneill
December 11th, 2002, 04:59 PM
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

theed
December 11th, 2002, 05:02 PM
[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.

Untitled
December 11th, 2002, 07:09 PM
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:

theed
December 11th, 2002, 08:12 PM
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.

Browni
December 12th, 2002, 12:41 PM
Im on 10.1.5.

Theres an advanced mode?

Were?

B

theed
December 12th, 2002, 02:54 PM
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.

Untitled
December 12th, 2002, 03:48 PM
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.

theed
December 12th, 2002, 05:12 PM
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.

Holmes
December 14th, 2002, 03:57 PM
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.

holmBrew
December 16th, 2002, 05:12 PM
start bc useing the 'l' flag
-=-=-=-=-=-
[localhost:~] holmbrew% bc -l
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/3
3.33333333333333333333
=-=-=-=-=-
[localhost:~] holmbrew% 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/3
3

blairh
December 16th, 2002, 10:36 PM
I hate the OSX Calculator. The OS9 one worked fine, and when I pushed a button, it actually came up in the screen! whoa!
Now, It just freezes up my computer for 2-3 seconds, gives me the beach ball, then displays the number. How can a calculator be this bad when Adobe Photoshop runs fine?!!!

Pawn Trader
December 17th, 2002, 07:38 PM
All other problems aside, I figured out how to eliminate that half-beat pause between the typed number and the on-screen display: minimize it.

I would guess that means the perceived speed problem is just sloppy work with Interface Builder?

Untitled
December 17th, 2002, 08:11 PM
Perhaps apple only compiled it with project builder set to "debug" when compiling it instead of deploy (cant remember the exact settings off the top of my head). That would make sense too since it kinda buggy :P

theed
December 17th, 2002, 08:49 PM
We know far too little of the calculator to speculate further. We have said far more than we can verify already. The calculator has issues, but it's a throwaway demo app.

Please, to improve the signal to noise ratio of this forum, let this thread die. If anyone does bring this thread back to life, I recommend starting with the phrase:

"Take that! You stupid, dead horse."