How does my pocket calculator do this?
March 28, 2004 10:06 AM
Subscribe
How does my pocket calculator do this?
I've got an old pocket calculator that I'm playing around with when I'm bored. If I enter a very small number, like 1.000,000,001, and raise it to the power of 1011 it takes less than two seconds to get the answer. I don't know much about computing but I don't think my ten year old calculator can multiply that number by itself 100 billion times within two seconds. So how does it do it? Does it use some kind of mathematical shortcuts?
More about calculators cutting corners if anyone's interested. At work, we sell calculators. Once a girl came back and complained about her Texas Instruments TI-83 graphical calculator: it gave the wrong answer. She showed me: a calculation where the result should be exactly zero was not zero but a very small number. This was beyond me, so I called Texas customer support, and they explained that this was because of the algorithm the calculator used. In other words, it's not a bug, it's a feature. But a cheap 12 dollar calculator was able to give the correct answer.
posted by Termite to technology (6 comments total)
log(x^y) = y * log(x), so x^y = invlog(y * log(x))
in that case the calculator would need to know how to calculate the logairthm from a number (log(...)) and get a number back from a logarithm (invlog(...)). there are ways to do this (i think it's what babbage was trying to do, in a way, with his mechanical computers).
your other point, about small differences, is because calculators can't store some fractions that you can write down easily in decimal as binary. for example 1/2 is 0.5 in decimal and 0.1 in binary, but 9/10, which is 0.9 in decimal, is something like 0.1110011... (it keeps going for ever, just like 1/3 is 0.33333.... in decimal).
so some numbers aren't stored exactly in a calculator and this lets errors creep in. different calculators handle this in different ways. some display less digits than they have information for, so a very small number would be displayed as 0. that's probably what is happening in your case (either that or it uses slightly different algorithms which, in that particular example, didn't give an error - perhaps because two errors cancelled each other out!)
posted by andrew cooke at 10:48 AM on March 28, 2004