Guard digits

Guard digits are additional bits used during intermediate floating-point calculations to preserve precision and minimize rounding errors, particularly in operations like subtraction where significant digits may cancel out. Although these digits do not appear in the final stored result, they play a critical role in maintaining numerical stability and correctness in floating-point systems.

How guard digits work

One or more guard digits can be used in floating-point arithmetic to extend the significand (also called mantissa) during internal computations. IEEE 754 arithmetic uses guard digits to improve accuracy during subtraction of nearly equal numbers, ensure correct rounding, and avoid catastrophic cancellation.

Typically, hardware implementations use 1 to 3 extra bits: a guard bit, a round bit, and a sticky bit. These bits are often collectively referred to as GRS bits, and aren't part of the final stored floating-point result - they are only for internal use during computation.

Addition and subtraction

When adding and subtracting floating point numbers of different exponents, smaller significands are shifted right, causing meaningful bits to shift out of range. Guard digits help catch those bits to preserve rounding accuracy.

Multiplication

The product of two significands of bit length is up to bits. Extra bits beyond the target precision can be caught in guard digits for rounding.

Division

Guard digits are used to maintain precision during long division, since division results may extend beyond the significand size.

IEEE Standards

In both IEEE standards on floating point arithmetic (IEEE 754 and IEEE 854), correct rounding is paramount. IEEE 754 specifies binary formats, permits internal extensions to precision, and encourages the use of GRS bits. IEEE 854 is a more general standard that supports both binary and decimal, leaving details like guard digits up to the implementation.

Both standards do not mandate guard digits, but GRS bits are a practical means to achieve correct rounding.

Was this page helpful?