In numerical analysis, one or more guard digits can be used to reduce the amount of roundoff error.
For example, suppose that the final result of a long, multi-step calculation can be safely rounded off to N decimal places. That is to say, the roundoff error introduced by this final roundoff makes a negligible contribution to the overall uncertainty.
However, it is quite likely that it is not safe to round off the intermediate steps in the calculation to the same number of digits. Be aware that roundoff errors can accumulate. If M decimal places are used in the intermediate calculation, we say there are M−N guard digits.
Guard Digits are also used in floating point operations in most computer systems. Given we have to line up the binary points. This means we must add an extra digit to the first operand—a guard digit. This gives us . Performing this operation gives us or . Without using a guard digit we have, yielding or . This gives us a relative error of 1. Therefore we can see how important guard digits can be.
An example of the error caused by floating point roundoff is illustrated in the following C code.
int main{ float a; int i; a = 0.2; a += 0.1; a -= 0.3; for(i=0 ; a<1.0 ; i++) a += a; printf(" i=%d a=%f\n",i,a); return 0; }It appears that the program should not terminate. Yet the output is : i=27 a=1.600000
Another example is:
Take 2 numbers:
2.56*10^0 and
2.34*10^2
we bring the first number to the same power of 10 as the second one:
0.0256*10^2
The addition of the 2 numbers is:
0.0256*10^2 +
2.3400*10^2
____________
2.3656*10^2
After padding the second number with 0, the bit after 4 is the guard digit and the bit after is the round digit. The result after rounding is 2.37 as opposed to 2.36 without the extra bits (guard and round bits), i.e. by considering only 0.02+2.34 = 2.36. The error therefore is 0.01.
Famous quotes containing the words guard and/or digit:
“Harsh necessity, and the newness of my kingdom, force me to do such things and to guard my frontiers everywhere.”
—Virgil [Publius Vergilius Maro] (7019 B.C.)
“Bless my soul, Sir, will you Britons not credit that an American can be a gentleman, & have read the Waverly Novels, tho every digit may have been in the tar-bucket?”
—Herman Melville (18191891)