I was playing around on the TI when i discovered that .99999999999999 prints as "1", while .999999999999999 prints as "1."

print .9 = ".9"

print .99 = ".99"

print .999 = ".999"

print .9999 = ".9999"

print .99999 = ".99999"

print .999999 = ".999999"

print .9999999 = ".9999999"

print .99999999 = ".99999999"

print .999999999 = ".999999999"

print .9999999999 = ".9999999999"

print .99999999999999 = "1"

print .999999999999999 = "1."

Actually, you have the last two backwards. The one with fourteen 9s after the decimal point prints “1.” and the one with fifteen 9s prints “1”.

The reason for this has to do with how the TI handles floating point numbers. They are represented as eight-byte, radix-100 (base-100 or centimal) numbers with the first byte having a sign bit followed by a 7-bit, excess-64 exponent capable of representing 100^{-64} – 100^{+63}. The remaining 7 bytes represent a normalized centimal significand, *i.e.*, if the number is non-zero, it is adjusted until the first digit is a non-zero, unit’s-place digit (radix-100 scientific notation). The largest such significand is 99 99 99 99 99 99 99 (separating the centimal digits (bytes) with spaces makes this clearer, I think), *i.e.*, fourteen decimal 9s. As soon as you enter a number that has more digits than can be exactly represented in 7 bytes, it is rounded.

Consequently, before printing, entering 0.99999999999999 is exactly represented internally as decimal 63 99 99 99 99 99 99 99 or hex 3F 63 63 63 63 63 63 63 (bytes are separated by spaces). However, entering more digits than can be exactly represented causes rounding of the internal representation, with 0.999999999999999 becoming exactly 1 and represented internally as decimal 64 01 00 00 00 00 00 00 or hex 40 01 00 00 00 00 00 00.

The PRINT function will print only 10 digits. It will round any number that contains more than 10 digits before printing and it will display a decimal point if the number had a non-zero fraction before rounding. Any number that has no fractional part will be treated by PRINT as an integer and will not have a decimal point. PRINT rounded the fraction with fourteen 9s. PRINT saw the number entered with fifteen 9s in the fraction as the integer “1”, so did not add a decimal point.

...lee