| fox@fury | ||||
|
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.
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:
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?
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:
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.
|
aboutme
Hi, I'm Kevin Fox. I also have a resume. electricimp
I'm co-founder in The Imp is a computer and wi-fi connection smaller and cheaper than a memory card. We're also hiring. followme
I post most frequently on Twitter as @kfury and on Google Plus. pastwork
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 |
|||