Rounding

The decimal expansion of a real number is rounded when it is approximated by a terminating decimal that has a given number of decimal digits to the right of the decimal point.

Rounding to decimal places is achieved by removing all decimal digits beyond (to the right of) the digit to the right of the decimal place, and adjusting the remaining digits where necessary.

If the first digit removed (the digit) is less than 5 the preceding digit is not changed.

For example, becomes when rounded to 3 decimal places.

If the first digit removed is greater than 5, or 5 and some succeeding digit is non-zero, the preceding digit is increased by 1. For example, becomes when rounded to 5 decimal places.