rounding


Rounding is a general technique for approximating a real number by a decimal fraction. There are several ways of rounding a real number, five of which are the most common: rounding up, rounding down, truncation, ordinary rounding (or rounding for short), and banker’s rounding.

Rounding to an Integer

The simplest kind of rounding is that of rounding a real number to an integer. Let r be a real number. Then

rounding up:

rounding up of r is taking the smallest integer that is greater than or equal to r. This integer is denoted by the ceiling function

r:=min{nnr}.

Examples: 2.1=3, and 62.672=63.

rounding down:

rounding down of r is taking the largest integer that is less than or equal to r. This integer is denoted by the floor function

r:=max{nnr}={rif r is an integerr-1otherwise.

Examples: 1.24=1, and -2.63=-3.

truncation:

rounding by truncation is done by ignoring all decimals to the right of the decimal point, which is equivalentMathworldPlanetmathPlanetmathPlanetmathPlanetmath to taking only the integer part of r. The truncation of r is denoted by [r]. In terms of rounding up and rounding down: we have

[r]={rif r0rif r<0.

If we write r as a decimal number using decimal expansion, then [r] is the integral portion of r.

Examples: [2.354]=2, and [-81.67]=-81.

ordinary rounding:

this is the most commonly used of the rounding methods described so far. (Ordinary) rounding of r is finding the closest integer to r, and if r is exactly half way between two integers, use the larger of the two as the result. Let R(r) represents the ordinary rounding of r. It is easy to see that

R(r)=r+0.5.

Examples: R(-3.37)=-3, while R(7.5)=8.

There is an easy algorithmMathworldPlanetmath of rounding r to the nearest integer.

  1. (a)

    write r as a decimal number using decimal expansion

  2. (b)

    if the tenths decimal place value is less than 5, then R(r)=[r]

  3. (c)

    if the tenths decimal place value is at least 5, then R(r)=[r]+1.

banker’s rounding:

a variant of the ordinary rounding is the banker’s rounding: if r is exactly half way between two integers, and the integer portion of r is even, round down r. Otherwise, use ordinary rounding on r. If B(r) denotes the banker’s rounding of r, then it can be defined as

B(r)={rif [r] is even, and 2rR(r)otherwise.

For example, B(3.5)=4, while B(2.5)=2.

stochastic rounding:

this rounding method requires the aid of a random number generatorPlanetmathPlanetmath. Rounding of r may be done using any of the above methods when r is not exactly half way between two consecutive integers. Otherwise, r is randomly rounded up or down based on the outcome of randomly selecting a number between 0 and 1 using a random number generator. The choice of rounding up (and thus down) depends on how numbers are in [0,1] are allocated for rounding up (or down).

alternate rounding:

this rounding method, like the last one, uses other available methods except when the number in question r is exactly half way between two consecutive integers. However, this method is used in a situation where a sequenceMathworldPlanetmathPlanetmath of numbers needs to be rounded:

  1. (a)

    the first number in the sequence is rounded using any of the above methods;

  2. (b)

    when the n-th number is rounded, the (n+1)-th number is rounded as follows: if the number is exactly half way between two consecutive integers, then it is rounded down if the n-th number is rounded up, and vice versa. Otherwise, use the rounding method used to round the first number in the sequence.

Rounding to a Decimal Fraction

More generally, the three methods described can be applied to rounding of r to a decimal fraction. The general procedure is as follows:

  1. 1.

    First, specify how accurately we want to round r. This can be accomplished by specifying to what decimal place we want to approximate r. Let this place be n (note that n>0 if it is to the right of the decimal point and n<0 otherwise).

  2. 2.

    Write r as a decimal number using decimal expansion.

  3. 3.

    Multiply r by 10n. By doing this, we are basically moving the decimal point so it is positioned between the n-th decimal place and the (n+1)-th decimal place.

  4. 4.

    Use any of the four methods above to round 10nr.

  5. 5.

    Divide the rounded number by 10n to get the result.

In practice, steps 3 through 5 can be combined into one step, simply by performing the rounding operationMathworldPlanetmath at the specified decimal place as if it were the ones place. For example, rounding π=3.14159 to the nearest thousandths place is 3.142, the thousandths place value 1 is increased to 2 because the ten thousandths place is 5.

Remark. In general, rounding to the n-th decimal place can be thought of as a function f from to D, the set of all decimal fractions, such that

  • |f(r)-r|10n, and

  • f(r)=r if 10nr.

If g: denotes any of the four rounding methods described in the previous sectionPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath, and gn corresponds to rounding to the n-th decimal place using method g in step 4 above, then the entire rounding process can be summarized by a single formulaMathworldPlanetmathPlanetmath:

gn(r)=g(10nr)10n.
Title rounding
Canonical name Rounding
Date of creation 2013-03-22 17:27:27
Last modified on 2013-03-22 17:27:27
Owner CWoo (3771)
Last modified by CWoo (3771)
Numerical id 10
Author CWoo (3771)
Entry type Definition
Classification msc 65G99
Classification msc 65D99
Classification msc 00A69
Classification msc 65G50
Synonym round up
Synonym round down
Synonym round to
Defines rounding up
Defines rounding down
Defines symmetric arithmetic rounding
Defines rounding error
Defines truncation
Defines rounded to
Defines banker’s rounding