Slashdot Mirror


If You Type 1+2+3 Into Your iPhone's Calculator on iOS 11, You Probably Won't Get 6 (qz.com)

A reader shares a report: If you've upgraded your iPhone's operating system to iOS 11, try this: Go to the calculator app and quickly type 1+2+3. You likely won't get 6. You might get 23, or 24, or 16, or 32, or something else, depending on what buttons you tap and in what order, and, obviously, none of which is the right answer. It seems to be because of a new animation in the calculator app, where a button briefly fades to white when you press it. The result is that if you press an operator button (i.e., the plus sign) before the short animation finishes, the app ignores it. So, 1 + 2 + 3 accidentally gets read as 1 + 23.

10 of 337 comments (clear)

  1. First CS assignment. by Anonymous Coward · · Score: 5, Informative

    After a basic hello world intro, I had to write a calculator to add subtract multiply and divide in the first week of college. Had mine worked like apples Iâ(TM)d have likely failed. How does this happen?

    1. Re:First CS assignment. by bjohnso5 · · Score: 2, Informative

      The Win10 calculator just gave me this result: -8.1648465955514287168521180122928e-39

    2. Re:First CS assignment. by nine-times · · Score: 5, Informative

      How does this happen?

      It explains how it happened in the summary:

      It seems to be because of a new animation in the calculator app, where a button briefly fades to white when you press it. The result is that if you press an operator button (i.e., the plus sign) before the short animation finishes, the app ignores it. So, 1 + 2 + 3 accidentally gets read as 1 + 23.

      It's not doing math wrong. It does a brief animation when you press a button, and it doesn't necessarily read the next button you press while the animation is happening. Therefore, if you press the calculator buttons too quickly, it won't register all the things you pressed. Based on the buttons you do press, it does the math correctly.

      So if you press "1+2+3" it might miss the second "+" and register "1+23" and give you "24" as an answer.

    3. Re:First CS assignment. by sexconker · · Score: 3, Informative

      It gets even weirder than that!

      4 @ - 2 = -8.1648465955514287168521180122928e-39 (@ is the shortcut for clicking the square root key)
      4 y .5 - 2 = 1.0605907030850721689734498566293e-38 (y is the shortcut for clicking the "x to the power of y" key)
      4 y ( 1 / 2 ) - 2 = -8.1648465955514287168521180122928e-39 (y is the shortcut for clicking the "x to the power of y" key)

      It even shows "0.5" after you type the closing parenthesis when doing 4 y ( 1 / 2 ). Yet the result differs compared to 4 y .5 - 2 (or 4 y 0.5 - 2).

      WTFOOK MS?

    4. Re:First CS assignment. by Anonymous Coward · · Score: 4, Informative

      Typical Apple. Form over function.

      It's actually the other way around - this happened for functional reasons. UIKit-based animations have an option to disable user interaction during an animation. This is switched on by default, and it has been since the very first version of the iPhoneOS SDK. It had to be switched on by default because otherwise, users who were used to double-clicking to activate things with mouse-based interfaces would trigger actions twice when double-tapping on buttons (and yes, if you watch non-technical people, absolutely loads of them double-click and double-tap even when they don't have to). Auto-disabling user interaction during animations is the smartest default.

      All that's happened here is that somebody in Apple forgot to switch that option off, and it's the kind of thing that's easily missed during testing. After all, despite what people say, this isn't new to iOS 11 - the bug has been present for a couple of years now and it's only just been noticed.

    5. Re:First CS assignment. by hey! · · Score: 4, Informative

      This isn't a math problem. It's basic programming; you don't rely on tests of equality between the results of floating point calculations and integer quantities.

      What's going on here is that the sqrt function yields a floating point number that's close to the integer 2, and that's rounded for display down to 2. The round for display routine clearly chooses not to round if the difference is large relative to the amount. For example take the number 1000, and add .00000000001. It will display 1000.00000000001. Now do the same with 1,000,000; it will display 1,000,000 even though internally the number is 1,000,000.00000000001.

      It's not an entirely unreasonably way of doing it, although most people would tend to round to a fixed number of digits.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    6. Re:First CS assignment. by Obfuscant · · Score: 3, Informative

      Wow, I could reproduce it easily in my updated 64-bit W7 HPE SP1 machine. Why hasn't MS fixed it?

      The hatred for Microsoft runs deep in this group, to ignore the fact that the calculations are actually being done by an IEEE-754 compliant floating point processor in the Intel or AMD CPU, and not by Microsoft doing it in their code.

      What's fun is having an 80 bit IEEE processing unit on a 64 bit CPU. You can get different answers depending on whether the calculations are done entirely in 80 bit FPU or 64 bit CPU.

      So, it isn't Microsoft's failure to fix. It's a known limitation of using a digital computer to "do math".

      You might pipe back that the computer could be written to work in arbitrary precision binary coded decimal, but that leaves the problem of errors at the edge of the precision, no matter what that precision is. Even "arbitrary" doesn't mean "unlimited", both for speed and hardware constraints.

  2. Re:Unable to reproduce. by 93+Escort+Wagon · · Score: 4, Informative

    I have an iPhone 6S on iOS 11.1 beta - and this bug is damn easy to reproduce. Why on earth does a freaking animation get precedence over a button push? More importantly, why is it even blocking at all?

    I'm old enough to remember typing on remote CRT terminals which were connected to a central computer over a 300 baud line (or maybe it was 110? This was back ~ 1980-1981). Back then, if you typed reasonably fast you could get ahead of the terminal's display by a few characters... but even way back then, this was a solved problem, those additional characters didn't get lost.

    --
    #DeleteChrome
  3. Re:Windows Calculator by eggz128 · · Score: 1, Informative

    Here, have a real Windows calc.exe bug (that's been there *forever*, across all the different versions)

    sqrt4 - 2 = ?

  4. Re:Windows Calculator by Obfuscant · · Score: 5, Informative

    How strange.

    Not strange at all. That is zero within "eps", and is because they are using the Intel or AMD math processor for the square root. WE look at "4" and know the square root is exactly two because we learned that. The CPU goes through a standard algorithm for determining the square root of a number, and because of the inherent imprecision of floating point math with a limited number of bits, the answer is not identical to zero because the square root of 4 is not identical to 2.