sult were exactly 0.99999999999, and
we could only display 10 characters
at a time, we would see an initial display of 1.00000000. As we scroll to see
more digits, we would successively see
...000000E- 6, then ...000000E- 7, and
so on until we get to ...00000E- 10, but
then suddenly ...99999E- 11. If we scroll
back, the screen would again show zeroes. We decided this would be excessively confusing, and thus try to truncate toward zero rather than rounding.
It is still possible for previously displayed digits to change as we are scrolling. But we always compute a number
of digits more than we actually need, so
this is exceedingly unlikely.
Since our goal is an error of strictly
less than one in the last displayed digit,
we will never, for example, display an
answer of exactly 2 as 1.9999999999.
That would involve an error of exactly one in the last place, which is too
much for us.
It turns out there is exactly one
case in which the display switches
between 9s and 0s: A long but finite
sequence of 9s (more than 20) in the
true result can initially be displayed
as a slightly larger number ending in
0s. As we scroll, the 0s turn into 9s.
When we immediately scroll back,
the number remains displayed as 9s,
since the calculator caches the best-known result (though not currently
We prevent 9s from turning into
0s during scrolling. If we generate a
result ending in 9s, our error bound
implies that the true result is strictly
less (in absolute value) than the value
(ending in 0s) we would get by incrementing the last displayed digit. Thus
we can never be forced back to generating zeros and explicitly ensure that
we always continue to generate 9s,
and 9s never turn into 0s.
Coping with Undecidability
The calculator essentially represents
a number as a program for computing approximations. This representation has many nice properties, like
never resulting in the display of incorrect results. It has one inherent
weakness: Exact equality of two numbers is fundamentally undecidable.
We can compute more and more digits of both numbers, and if they ever
differ by more than one in the last
Indicating position. We would like
the user to be able to see at a glance
which part of the result is currently being displayed.
Conventional calculators solve the
vaguely similar problem of displaying
very large or very small numbers by using scientific notation. We use the same
approach for the initial display.n If the
user enters “ 1÷3X10^ 20”, computing
1/3 times 10 to the 20th power, the result
may be displayed as 3.3333333333E19.
In this version of scientific notation,
the decimal point is always displayed
immediately to the right of the most
Once the decimal point is scrolled
off the display, this style of scientific notation is not helpful; it essentially tells
us where the decimal point is relative to
the most significant digit, but the most
significant digit is no longer visible. We
address this by switching to a different
variant of scientific notation, in which
we interpret the displayed digits as a
whole number, with an implied decimal
point on the right. Instead of displaying 3.3333333333E19, we hypothetically could display 33333333333E9 or
33333333333 times 109. In fact, we use
this format only when the normal scientific notation decimal point would not
be visible. If we had scrolled the above
result two digits to the left, we would
in fact be seeing ...33333333333E7.
This tells us the displayed result is very
close to a whole number ending in
33333333333 times 107. The two forms
of scientific notation are easily distinguishable by the presence or absence of
a decimal point, and the ellipsis character at the beginning.
Rounding vs. scrolling. Normally
we expect calculators to try to round
to the nearest displayable result.
If the actual computed result were
0.66666666666667, and we could
only display 10 digits, we would expect a result display of, for example
0.666666667, rather than 0.666666666.
For us, this would have the disadvantage that when we scrolled the result
left to see more digits, the “ 7” on the
right would change to a “ 6”. That
would be mildly unfortunate. It would
be somewhat worse if the actual re-
n Numbers that differ from zero by less than
10–320 may be displayed as 0.0000000000. See
section Coping with Undecidability.
Perhaps the most
arithmetic is that it
has trained us not
to even attempt