Computers use floating-point numbers to represent a finite subset of the
real numbers. As you have already seen, you write a floating-point number in
Maple by giving a mantissa and an optional exponent. For example, .125e5
stands for .125 times 10 raised to the fifth power, and .125 simply stands for
.125.
Maple, like most programming languages, keeps track of a floating-point number
by storing its mantissa together with its exponent. All languages impose
limits on the number of digits that are permitted in the mantissa and exponent.
To illustrate the practical meaning of such limits, let's consider a
hypothetical floating-point number system for representing positive real
numbers. (We'll ignore zero and negative numbers for now.) We will require
- the mantissa to be an integer between 1 and 9, inclusive, and
- the exponent to be either 1, 0, or -1.
Examples of floating-point numbers in our system are 1e1, 7e0, and 8e-1, which
represent 10, 7, and 0.8, respectively. How many different floating-point
numbers are possible in our system?
Click here for the answer
In our hypothetical system of floating-point numbers, then, the largest
possible number is 90 and the smallest is 0.1. Any real number in that range
is simply rounded to the closest floating-point number. For example, 88.12 is
rounded to 90, 2.82 is rounded to 3, and 0.52 is rounded to 0.5.
Of course, a number can be too big to be rounded in any reasonable way. For
example, 1283.33 is too large for our hypothetical system. (This is called
overflow.) A number can also be too small; for example, .0000088. (This is
called underflow.)
Now, if you were designing a floating-point system, how would you ensure that
both very large and very small numbers could be represented?
Click here for the answer
How would you ensure that all the real numbers between the largest and smallest
available floating-point numbers would have close approximations?
Click here for the answer
Now that you have this introductory material under your belt, let's discuss
floating-point numbers in the context of Maple.
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah