Calculator bug?

Discussion in 'Mac Apps and Mac App Store' started by Nermal, Nov 2, 2004.

  1. Nermal Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #1
    Calculator (v3.1) just gave me an interesting result.

    10339.01 + 66231.9 = 76570.90999999999

    :confused:
     
  2. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #3
    Oh no, not a repost, please save us all of you who can do searches. It isn't that big of a deal, if you don't like the reposts then don't read them. But yes, calculator is crafty some times.
     
  3. russed macrumors 68000

    russed

    Joined:
    Jan 16, 2004
    Location:
    London, England
    #4
    i think that prob should be fixed when 10.3.6 comes out soon. that is one of the areas that is being updated.
     
  4. MisterMe macrumors G4

    MisterMe

    Joined:
    Jul 17, 2002
    Location:
    USA
    #5
    The result may be "interesting," but it is not "wrong."
     
  5. Nermal thread starter Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #6
    Yeah, sorry, I didn't search because I was doing a non-resumable download at the same time, so browsing was like being back on a 14.4 modem again :eek:

    Care to explain how that is not wrong? Sure, it's correct if you round it, but if you don't round it then it certainly is wrong!
     
  6. Freg3000 macrumors 68000

    Freg3000

    Joined:
    Sep 22, 2002
    Location:
    New York
    #7
    Under the theory that
    1/3 = .33333333 non-terminating,
    2/3 = .66666666 non-terminating,

    so 1/3 + 2/3 = .99999999999 non-terminating = 3/3 = 1

    76570.90999999999 = 76570.91

    That's what I think he meant anyway. :)
     
  7. MisterMe macrumors G4

    MisterMe

    Joined:
    Jul 17, 2002
    Location:
    USA
    #8
    Freg3000 is on the right track. What you see as a bug is merely the age-old artifact of doing floating-point decimal math in binary. Hardware calculators usually do math in binary-coded decimal. Computer-based calculator emulators usually do math in binary and then convert the result to decimal. This conversion step may introduce the string of 9's. Apple's programmers have chosen not to round-off the result, but the answer is correct to the proper number of significant figures.
     
  8. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #9
    Yes, those numbers are represented in binary in memory, but the inaccuracy is not the fault of binary arithmetic. It has to do with the fact that a calculater/computer only have a fixed (finite) amount of memory to represent a floating point number, so some precision is lost.
     
  9. molcas&e'sdad macrumors member

    Joined:
    Sep 15, 2003
    Location:
    Minnesota.
    #10
    I think that I find a "bug" in calculator every time I try to balance my checkbook ... ;)
     
  10. MisterMe macrumors G4

    MisterMe

    Joined:
    Jul 17, 2002
    Location:
    USA
    #11
    Handheld calculators have much less available memory than just about any computer-based calculator.
     
  11. Nermal thread starter Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #12
    As of version 3.2 (included with 10.3.6), it now works as expected :)
     
  12. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #13
    not total memory...but allocated memory :rolleyes: In most cases calculators have the same precision as a computer - 64 bit decimal representation, unless you are using customized data types - such as BigDecimal in Java...
     

Share This Page