19.4 Overflow and Underflow

I l @ ve RuBoard

There are limits to the size of the number a computer can handle. What is the result of the following calculation?

9.000E+9 x 9.000E+9

Multiplying it out, we get:

8.1 x 10 19

However, we are limited to a single-digit exponent, too small to hold 19. This is an example of overflow (sometimes called exponent overflow). Some computers generate a trap when this occurs, thus interrupting the program and causing an error message to be printed. Others are not so nice and generate a wrong answer (like 8.100E+9). Computers that follow the IEEE floating-point standard generate a special value called +Infinity .

Underflow occurs when the numbers become too small for the computer to handle. Example:

1.000E-9 x 1.000E-9

The result is:

1.0 x 10 -18

Because -18 is too small to fit into one digit, we have underflow. Again, like overflow, the results of underflow are system-dependent.

I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net