We told you earlier that in Maple, floating-point numbers can have up
to ten digits in their mantissas. Let's see some evidence of this.
If we multiply two six-digit numbers, we get a ten-digit answer:
| 123.456 * 987.654; |
If you try a few more, you'll see that you never get more than ten digits in
the mantissa.
The statement that Maple allows only ten-digit mantissas is actually
inaccurate. You can tell Maple how many digits to use in its mantissas, which
is handy in the event that you would like more or less precision. For example,
you can ask Maple to use five-digit mantissas by issuing this command:
| Digits := 5; |
Try repeating the multiplication that you did earlier with five-digit
mantissas.
Maple will also allow extremely large positive and negative exponents:
| 123.456e789 * 987.654e3210; |
The limit on the size of exponents depends upon exactly what version of Maple,
and what kind of computer, you are using.
Now, suppose that you take two floating point numbers, multiply them using
Maple, and examine the answer. Will your answer be exact?
Click here for the answer
Every time that you do a floating-point operation, such as multiplication or
division, you can incur a small amount of error. If you are doing a long
sequence of floating-point operations, these errors can add up. If you are
only doing a few operations, though, there is a simple precaution you can take
that will usually ensure that the floating-point error will be negligible.
Simply make sure that the mantissa is a good bit more precise than the numbers
you are manipulating.
For example, if you are multiplying two numbers that are accurate to three
significant digits, then using a six-digit mantissa will usually ensure that
the floating-point error will affect only the insignificant digits in the
ultimate answer. This is not always the case unless you exercise care, though,
as we will see in the next two sections.
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah