Summary: How computers represent numbers in bits.
Computers express numbers in a fixed-size collection of bits, commonly known as the computer's word length. Today, word-lengths are either 32 or 64 bits, corresponding to a power-of-two number of bytes (8-bit "chunks"). This design choice restricts the largest integer (in magnitude) that can be represented on a computer.
For both 32-bit and 64-bit integer representations, what is the largest number that can be represented? Don't forget that the sign bit must also be included.
For
When it comes to expressing fractions, positional notation is
easily extended to negative exponents using the decimal point
convention: Wherever the decimal point occurs in a string of
digits, we know that the first digit to the left corresponds to
the zero exponent, and the one to the right is
What are the largest and smallest numbers that can be represented in 32-bit floating point? 64-bit floating point that has sixteen bits allocated to the exponent? Note that both exponent and mantissa require a sign bit.
In floating point, the number of bits in the exponent
determines the largest and smallest representable numbers.
For 32-bit floating point, the largest (smallest) numbers
are
So long as the integers aren't too large, they can be
represented exactly in a computer using the binary positional
notation. Electronic circuits that make up the physical computer
can add and subtract integers without error. However, this
statement isn't quite true; when does addition cause problems?
Floating point representation handles numbers with fractional
parts, but only some with no error. Similar to the integer
case, the number could be too big or too small to be so
represented. More fundamentally, many
numbers cannot be accurately represented no matter how many bits
are used for the exponent and mantissa. For example, you know
that the fraction
Can
If the base is a multiple of three, then
Clearly, many numbers have infinite expansions, and this situation applies to binary expansions as well. Consequently, number representation and arithmetic performed by a computer cannot be infinitely accurate in most cases. The errors incurred in most calculations will be small, but this fundamental source of error can cause trouble at times.