Saturday, August 15, 2009

Overflow and underflow

Computers use a binary scheme having only the two binary digits 0 and 1 to represent data. So the range of values that can be represented is limited. Many computers use 32 bits to store integers. The largest unsigned integer that can be stored is 2^32 = 4294967296. The first bit is used to represent the sign, so, in fact, the larget value is 2^31 - 1 = 2147483647.

The situation where an integer outside the allowed range requires more bits than can be stored is called an overflow. Similarly, with real numbers, an exponent that is too small to be stored causes an underflow.

NOTE: Different computers have different storage sizes for values.



Previous post

Next post




No comments:

Post a Comment