Precision Loss and Overflow
Because fixed point operations can produce results that have more bits than the operands, there is possibility for information loss. For instance, the result of fixed point multiplication could potentially have as many bits as the sum of the number of bits in the two operands. In order to fit the result into the same number of bits as the operands, the answer must be rounded or truncated. If this is the case, the choice of which bits to keep is very important. When multiplying two fixed point numbers with the same format, for instance with integer bits, and fractional bits, the answer could have up to integer bits, and fractional bits.
For simplicity, many fixed-point multiply procedures use the same result format as the operands. This has the effect of keeping the middle bits; the I-number of least significant integer bits, and the Q-number of most significant fractional bits. Fractional bits lost below this value represent a precision loss which is common in fractional multiplication. If any integer bits are lost, however, the value will be radically inaccurate. Some model-based fixed-point packages allow you to specify a result format different from the input formats. This allows you to maximize precision and avoid overflow.
Some operations, like divide, often have built-in result limiting so that any positive overflow results in the largest possible number that can be represented by the current format. Likewise, negative overflow results in the largest negative number represented by the current format. This built in limiting is often referred to as saturation.
Some processors support a hardware overflow flag that can generate an exception on the occurrence of an overflow, but it is usually too late to salvage the proper result at this point.
Modern development cycles include a prototyping phase which examines the potential precision loss and overflow of designs using fixed point calculations before proceeding to physical prototyping.
Read more about this topic: Fixed-point Arithmetic
Famous quotes containing the words precision, loss and/or overflow:
“One can prove or refute anything at all with words. Soon people will perfect language technology to such an extent that they’ll be proving with mathematical precision that twice two is seven.”
—Anton Pavlovich Chekhov (1860–1904)
“A gain is no joy, nor a loss any grief.”
—Chinese proverb.
“Oh! that thy love might overflow my Heart!
To fire the same with Love: for Love I would.
But oh! my streight’ned Breast! my Lifeless Sparke!
My Fireless Flame! What Chilly Love, and Cold?
In measure small! In Manner Chilly! See!
Lord, blow the Coal: Thy Love Enflame in mee.”
—Edward Taylor (1645–1729)