There's a bug in iPhone's calculator
Monday, Jul 02, 2007
First off, I love, love, love my iPhone. That said, I found my first actual undeniable iPhone bug yesterday. There seem to be a few unresolved issues with the iPhone's calculator. If you have an iPhone, you can follow along at home.
  • Open the calculator
  • Press 'C' if there's currently a number in the register
  • press '4', '+', '5', and '='. As you might expect, you get '9'.
  • Press the 'home' button on the phone to return to the phone's launch page.
  • Now say you want to add 3 and 8. Re-open the calculator. After a moment you'll see the '9' return to the register. Nice, and expected.
  • Press '3'. Instead of clearing the register and showing '3', it appends the 3 to the existing 9 and now you have '93'. This means that every time you launch the calculator you have to clear the current entry before doing a calculation.

This is a strange issue so I had to go to Apple's desktop widget calculator to get a few facts straight. The desktop widget, like a conventional calculator, treats '=' as a terminal action, and will automatically clear the register if the next keypress is a digit. The hiding or showing of the widget has no bearing on the calculator's state. For example, if you're entering your bank account balance into the calculator and forget what the cents were you can exit the dashboard, look it up, re-invoke the dashboard and finish typing the number. On the other hand, if you finish a calculation by hitting '=' and leave the dashboard the number will still be displayed upon your return, but pressing any number will clear the register and start a new calculation. This is the same behavior as if you never left the calculator.

The iPhone's calculator doesn't seem to remember its full state, only the last number in the register. You can exit out of the calculator to lok up a number and come back and finish entering it, but if you've finished a calculation and leave the calculator, it's forgotten that you're not still in the middle of typing a number, forcing you to hit 'C' before you start.

If that were the extent of the problem it would be only mildly strange, but here's where it gets a lot weirder:

  • Open the calculator
  • Press 'C' to clear the register
  • Calculate '5 divided by 8'
  • Press the 'home' button and return to the launch page
  • Re-open the calculator
  • Watch carefully: The display says '0.625' Now press '5'. the display now says '11.25'! Press '4' and it now says '116.5'! What strange witchcraft is this?

It appears that the calculator uses the following logic to enter digits: On keypress 'N', multiply the register by 10 and add N. Following this logic, when the computer has '0.625' in the register and you press '5' it first multiplies 0.625 by 10, yielding 6.25, then adds 5 to it, totaling 11.25. On pressing 4 you get 11.25 * 10 + 4, or 112.5 + 4, or 116.5.

That solves the mystery for adding integers, but how does the calculator add the portion to the right of the decimal point?

  • Go to the calculator, enter 5 / 8, close and re-open the calculator.
  • Type '.'. Everything looks good and the display resets itself to '0.'!
  • Now type '2': You get 0.8.
  • Type '2' again: 0.84.
  • Type '2' again: 0.847.
  • Type '2' again: 0.8472.
  • Type '2' again: 0.84722.

This is basically the same bug, but it also demonstrates that the display register and the actual register aren't the same. When you typed '.' it automatically set the display to show zero significant digits of the actual register, so while the register still contained '0.625' it was only showing the '0.' portion. Pressing '2' pushed the display register to show one more significant digit (0.6), and added '2' to the least significant visible digit, yielding '0.8'. Pressing '2' again pushed the display to 0.82 and added 2 to the least significant visible digit, making 0.84. Pressing '2' again turned 0.825 to 0.827. Since subsequent digits were all zeroes, subsequent '2' presses behaved normally.

There are other oddities as well, mostly having to do with rounding that happens between the memory register and the display register. For example:

  • Divide 97 by 100 to yield 0.97.
  • Quit and re-open.
  • Press '.': The display now reads '1.', because that's 0.97 rounded to zero significant digits.

But wait, 0.625 rounded to zero significant digits is also 1! It appears that the relevant rounding occurs two significant digits below the current display. '0.94' closed, reopened, and '.'ed gets you '0.', as does '0.948', however '0.95' gets you '1.'

The point is that there are still a few bugs in the calculator, so be sure to hit 'C' before starting a new calculation, because some manifestations of the bug might not be quite so obvious when you're punching in a string of numbers.

If you like it, please share it.

Hi, I'm Kevin Fox.
I've been blogging at since 1998.
I can be reached at .

I also have a resume.


I'm co-founder in
a fantastic startup fulfilling the promise of the Internet of Things.

The Imp is a computer and wi-fi connection smaller and cheaper than a memory card.

Find out more.

We're also hiring.


I post most frequently on Twitter as @kfury and on Google Plus.


I've led design at Mozilla Labs, designed Gmail 1.0, Google Reader 2.0, FriendFeed, and a few special projects at Facebook.

©2012 Kevin Fox