Section 21.1: Real numbers inside computer memories (Frame 4)                     [prev][home][next]

Methods of encoding floating point numbers in a computer differ from scientific notation. In computers the base is almost always a power of 2 and the mantissa has a fixed number of digits past the decimal point (actually the "binary point" since the base is not 10). Naturally, the mantissa is encoded in binary, rather than decimal, since the computer can only store binary. The mantissa is usually a fraction between 0 and 1.0, not including 1.0, which is also different from scientific notation which goes from 1.0 up to 10.0.

The number of digits past the decimal point is called the precision of the number. In some cases, like 1/3 or 1/7, the digits repeat forever in a regular pattern. In other cases, such as with π, the digits repeat forever but there is no pattern. The only way to really handle such numbers, called irrationals, is to stop after a certain number of digits. Though some computers have programs to do rational arithmetic, being able to manipulate fractions like 1/3 or 1/7 precisely, the usual approach is to turn them into decimals and also chop them off after a certain number of places to the right of the decimal point. Obviously, the more digits we write after the decimal point, the more information we convey, but the more room we take up in the computer's memory to store this.