Interactive Educational Modules in
Scientific Computing

Rounding Rules

This module demonstrates the effect of different rules for rounding a given decimal number to a smaller number of digits. If a given real number is not exactly representable as a floating-point number, then it must be approximated by some nearby floating-point number, a process called rounding. Two commonly used rounding rules are

  • chop, in which the base-β expansion is truncated after the (p−1)st digit, where p is the precision of the target system, and
  • round to nearest, in which the nearest floating-point number is chosen as the approximate value.

Round to nearest is the more accurate of the two, and is the default rounding mode in IEEE floating-point arithmetic.

The user selects values for the input and output precisions, and then either enters explicitly or chooses randomly a value to be rounded. The chosen number is then rounded by clicking the button for the desired rounding rule.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 1.3.4, especially Example 1.10.

Developers: Nicholas Exner and Michael Heath