What Is Rounding?

Rounding is the transformation of a number expressed in a particular base to a number with fewer digits. For example, in base 10 we might round the number x = 7.146 to 7.15, which can be described as rounding to three significant digits or two decimal places. Rounding does not change a number if it already has the requisite number of digits.

The three main uses of rounding are

  • to simplify a number in base 10 for human consumption,
  • to represent a constant such as 1/3, \pi, or \sqrt{7} in floating-point arithmetic,
  • to convert the result of an elementary operation (an addition, multiplication, or division) on floating-point numbers back into a floating-point number.

The floating-point numbers may be those used on a computer (base 2) or a pocket calculator (base 10).

Rounding can be done in several ways.

Round to Nearest

The most common form of rounding is to round to the nearest number with the specified number of significant digits or decimal places. In the example above, the two nearest numbers to x with three significant digits are 7.14 and 7.15, at distances 0.006 and 0.004, respectively, from x. The nearest of these two numbers, 7.15, is chosen.

What happens if the two candidate numbers are equally close? We need a rule for breaking the tie. The most common choices are

  • round to even: choose the number with an even last digit,
  • round to odd: choose the number with an odd last digit.

If we round 1.85 to two significant digits, the result is 1.8 with round to even and 1.9 with round to odd.

There are several reasons for preferring to break ties with round to even.

  • In bases 2 and 10 a subsequent rounding to one less place does not involve a tie. Thus we have the rounding sequence 2.445, 2.44, 2.4, 2 with round to even, but 2.445, 2.45, 2.5, 3 with round to odd.
  • For base 2, round to even results in integers more often, as a consequence of producing a zero least significant bit.
  • In base 10, after round to even a rounded number can be halved without error.

IEEE Standard 745 for floating-point arithmetic supports three tie-breaking methods: round to even (the default), round to the number with larger magnitude, and round towards zero (introduced in the 2019 revision for use with the standard’s new augmented operations).

The tie-breaking rule taught in UK schools, for decimal arithmetic, is to round up on ties. The rounding rule then becomes: round down if the first digit to be dropped is 4 or less and otherwise round up.

Round Towards Plus or Minus Infinity

Another possibility is to round to the next larger number with the specified number of digits, which is known as round towards plus infinity (or round up). Then 1.85 rounds to 1.9 and -2.34 rounds to -2.3. Similarly, with round towards minus infinity (or round down) we round to the next smaller number, so that 1.85 rounds to 1.8 and -2.34 rounds to -2.4.

This form of rounding is used in interval arithmetic, where an interval guaranteed to contain the exact result is computed in floating-point arithmetic.

Round Towards Zero

In this form of rounding we round towards zero, that is, we round x down if x > 0 and round it up if x < 0. This is also known as chopping, or truncation.

Stochastic Rounding

Stochastic rounding was proposed in the 1950s and is attracting renewed interest, especially in machine learning. It rounds up or down randomly. It come in two forms. The first form rounds up or down with equal probability 1/2. To describe the second form, let x be the given number and let x_1  x be the candidates for the result of rounding. We round up to x_2 with probability (x-x_1)/(x_2-x_1) and down to x_1 with probability (x_2-x)/(x_2-x_1); note that these probabilities sum to 1. In floating-point arithmetic, stochastic rounding overcomes the problem that can arise in summing a set of numbers whereby some individual summands are so small that they do not contribute to the computed sum even though they contribute to the exact sum.

The diagrams below illustrate round to nearest (RN), round towards zero (RZ), round towards plus infinity (\mathrm{R}^{+\infty}), and round towards minus infinity (\mathrm{R}^{-\infty}). They show the number x to be rounded in four different configurations with respect to the origin and the midpoint (drawn with a dotted line) of the interval between the two candidate rounding results (drawn with a solid line). The red arrows point to the two possible results of rounding.


Real World Rounding

The European Commission’s rules for converting currencies of Member States into Euros (from the time of the creation of the Euro) specify that “half-way results are rounded up” (rounded to plus infinity). (PDF link)

The International Association of Athletics Federations (IAAF) specifies in Rule 165 of its Competition Rules 2018–2019 that all times of track races up to 10,000m should be recorded to a precision of 0.01 second, with rounding to plus infinity. In 2006, the athlete Justin Gatlin was wrongly credited with breaking the 100m world record when his official time of 9.766 seconds was rounded down to 9.76 seconds. Under the IAAF rules it should have been rounded up to 9.77 seconds, matching the world record set by Asafa Powell the year before. The error was discovered several days after the race.

In meteorology, rounding to nearest with ties broken by rounding to odd is favoured. Hunt suggests that the reason is to avoid falsely indicating that it is freezing. Thus 0.5^\circC and 32.5^\circF round to 1^\circC and 33^\circF instead of 0^\circC and 32^\circF.

Useful Tool

The \LaTeX package siunitx has the ability to round numbers (in base 10) to a specified number of decimal places or significant figures.


This is a minimal set of references, which contain further useful references within.

Related Blog Posts

  • What Is Floating-Point Arithmetic? (2020)—forthcoming
  • What Is IEEE Standard Arithmetic? (2020)—forthcoming

This article is part of the “What Is” series, available from https://nhigham.com/category/what-is and in PDF form from the GitHub repository https://github.com/higham/what-is.

This entry was posted in what-is. Bookmark the permalink.

1 Response to What Is Rounding?

  1. Chris Johnson says:

    Interesting to hear that stochastic rounding is attracting interest again after 70 years. I learned of this technique from my late grandfather, who used it when designing the ALU of the Harwell Dekatron computer in ~1949. Although the hardware implementation was simple, in retrospect he felt that the machine was rather limited by being unable to repeat calculations exactly. A 1951 article by him and colleagues in ‘Electronic Engineering’ has the (non-mathematical) details ( http://www.computerconservationsociety.org/witch5.htm )

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s