Yikes! Calculator bug?

Discussion in 'Mac OS X System & Mac Software' started by Untitled, Dec 9, 2002.

Thread Status:
Not open for further replies.
  1. Untitled

    Untitled Untitled

    Joined:
    Apr 23, 2001
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Webmaster/Programmer/Hardware/Student
    Location:
    Virginia
    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
     
  2. Captain Code

    Captain Code Moderator Staff Member Mod

    Joined:
    Aug 29, 2001
    Messages:
    3,113
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Software Engineering Student
    Location:
    Ontario, Canada
    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!!!
     
  3. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    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.
     
  4. boi

    boi official breaker of macs.

    Joined:
    Sep 27, 2001
    Messages:
    933
    Likes Received:
    0
    Trophy Points:
    0
    it used to run slow for me, but for some reason it mysteriously stopped.
    i use koala calc.
     
  5. Untitled

    Untitled Untitled

    Joined:
    Apr 23, 2001
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Webmaster/Programmer/Hardware/Student
    Location:
    Virginia
    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....
     
  6. chemistry_geek

    chemistry_geek Registered

    Joined:
    Mar 26, 2001
    Messages:
    1,310
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Pharmaceutical Scientist
    Location:
    Hackensack, NJ, USA
    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.
     
  7. btoneill

    btoneill keeper of the cheese

    Joined:
    Jul 8, 2002
    Messages:
    797
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Unix Geek
    Location:
    Minneapolis, MN
    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
     
  8. michaelsanford

    michaelsanford Translator, Web Developer

    Joined:
    Oct 7, 2002
    Messages:
    2,277
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Translator & Web Developer
    Location:
    Ottawa/Montréal
    My fav's PCalc2, way better than Apple's little pocket-jobby.
     
  9. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    My problem with bc is that 10/3 gives you 3
     
  10. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    same as above.
     
  11. chevy

    chevy Maverlous Da Vinci Staff Member Mod

    Joined:
    Nov 11, 2001
    Messages:
    4,003
    Likes Received:
    1
    Trophy Points:
    38
    Occupation:
    High tech project mgt
    Location:
    Inside the black box, CH
    did you try 10.0 / 3 ?
     
  12. btoneill

    btoneill keeper of the cheese

    Joined:
    Jul 8, 2002
    Messages:
    797
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Unix Geek
    Location:
    Minneapolis, MN
    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
     
  13. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    [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.
     
  14. Untitled

    Untitled Untitled

    Joined:
    Apr 23, 2001
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Webmaster/Programmer/Hardware/Student
    Location:
    Virginia
    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:
     
  15. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    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.
     

    Attached Files:

  16. Browni

    Browni Registered

    Joined:
    Jan 6, 2002
    Messages:
    576
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student...a poor one at that!
    Location:
    Wantage, Oxfordshire, England
    Im on 10.1.5.

    Theres an advanced mode?

    Were?

    B
     
  17. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    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.
     

    Attached Files:

  18. Untitled

    Untitled Untitled

    Joined:
    Apr 23, 2001
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Webmaster/Programmer/Hardware/Student
    Location:
    Virginia
    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.
     
  19. theed

    theed Registered

    Joined:
    Dec 20, 2000
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    computer support for smart people studying old peo
    Location:
    PA or MD, USA
    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.
     
  20. Holmes

    Holmes Humble God

    Joined:
    Mar 28, 2001
    Messages:
    133
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student / Programmer dude
    Location:
    Santa Rosa, Ca
    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.
     
Thread Status:
Not open for further replies.

Share This Page