What is the mathematical notation for rounding a given number to the nearest integer?

24.2k Views Asked by At

What is the mathematical notation for rounding a given number to the nearest integer? So like a mix between the floor and the ceiling function.

8

There are 8 best solutions below

7
On BEST ANSWER

I have seen $\lfloor x \rceil$. It must have been in the context of math olympiads, so I can't point to a book that uses it. Wikipedia suggest this notation, among others: nearest integer function.

Personally, I would prefer $[x]$, being a cleaner mix of $\lfloor x \rfloor$ and $\lceil x \rceil$. But I've seen this notation being used for the floor function. Especially in older texts, say, pre-TeX era.

You could also do something like $\mathrm{nint}(x)$, but in formulas that could be cumbersome.

See also the remarks at Mathworld.

4
On

I have seen the notation $[x]$. However, that is some times used as the floor function when TeX is unavailable, or the author is unfamiliar with it (I'm sure there are plenty of examples on this site, for instance).

The safest bet is to say something along the lines of

Let $[x]$ mean the integer closest to $x$ (rounding up for half-integer values).

or

Let $[\phantom x]$ denote the standard rounding function.

That is, explicitly defining the notation yourself, so that anyone who reads your text knows exactly what you're talking about. If you do this, you are of course entirely free to "invent" your own notation (within reason) for this if there is some other notation you prefer.

5
On

Whatever notation you use (punctured dusk gives some good suggestions), you should always define this explicitly if you are going to use it, since there is no standard way to treat half-integers. (I recently found this out the hard way when I assumed the rounding method I was always taught was standard, but python's default does something different.)

1
On

Although I'm not sure how common this is in pure maths settings, I would say the best notation is simply $\operatorname{round}(x)$. This is easily understood, albeit not completely unambiguous – but definitely better than $[x]$ which could mean a myriad of completely unrelated things, or $\operatorname{nint}(x)$ which looks like “ninn-t?”

If the ambiguity $1 \stackrel?= \operatorname{round}(1.5) \stackrel?= 2$ is a problem for you, make sure to explicitly discuss this. If you use the operation a lot, you could also define that you write it as $\lfloor x\rceil$, but I wouldn't use that without discussion.

round is also the name for the rounding function in many programming languages, because what it does is it rounds a number, hence the name “round”.

0
On

I have seen $(\!(x)\!)$ for "nearest integer." My memory is dim, but maybe it was Emil Grosswald's elementary number theory text. I like it because it's easy to type and it's not likely to be confused with another function.

0
On

If you are fine going always in one direction for halfway values, you can resort to the programming trick of using $\lfloor x + \frac{1}{2} \rfloor$ (halfways towards $+\infty$) or $\lceil x - \frac{1}{2} \rceil$ (halfways towards $-\infty$).

0
On

It might be too verbose, but something like the following is unlikely to be misinterpreted.

$$\mathrm{RoundToEven}(5.5) = 6$$

If you need another convention such as rounding to the nearest odd number, rounding towards infinity, or rounding towards negative infinity I'd define my own function and include some examples.

For instance:


Let $R \mathop: \mathbb{R} \to \mathbb{Z}$ denote the function that rounds each real number to the nearest integer, rounding ties towards negative infinity.

$$ R(-0.5) = -1 $$ $$ \left\{ R(-0.3)\;,\; R(0)\;,\; R(0.3)\;,\; R(0.5) \right\} = \left\{ 0 \right\} $$ $$ R(1.5) = 1 $$ $$ R(1.7) = 2 $$

0
On

The short and sweet is that there is no short and sweet. Rounding has many different contexts and interpretations, which means that you will have to define what rounding means to you in your particular context before your use it. Now, there is standard notation for two specific types of rounding. $\lceil\text{Ceiling}\rceil$ brackets indicate that you always round up toward positive infinity, e.g. $\lceil1.1\rceil = 2$ and $\lceil-3.9\rceil = -3$, and $\lfloor\text{floor}\rfloor$ brackets indicate that you always round down toward negative infinity, e.g. $\lfloor2.9\rfloor=2$ and $\lfloor-6.1\rfloor=-7$.

Now, if we wish to define the typical elementary/secondary school form of rounding where you need to specify how many decimal places you wish to round to, and halves always gets rounded up, then we could do so as follows:

For $d \in \mathbb Z$, let $R_d:\mathbb R \rightarrow \mathbb Z$ such that $$R_d(x) = \frac{\lfloor10^d x + 0.5\rfloor}{10^d}$$

Note that this method creates a bias towards positive infinity and as such the rounding behavior for positive and negative numbers seems incongruous for some. In response to this, some elementary/secondary classes may then adopt the following adaptation that addresses this incongruity as follows:

For $d \in \mathbb Z$, let $R_d:\mathbb R \rightarrow \mathbb Z$ such that $$R_d(x) = \begin{cases} \dfrac{\lfloor10^d x + 0.5\rfloor}{10^d}, &x\text{ is nonnegative} \\ \dfrac{\lceil10^d x - 0.5\rceil}{10^d}, &x\text{ is negative} \end{cases}$$

Now $R_0(4.5) = -R_0(-4.5)$! Students rejoice! (Though subsequent teachers unaware of this adaptation will cringe) This even has bias eliminating implications when dealing with aggregate data, however not all bias has been eliminated. The positive bias more or less balances with the negative bias if your mean is at or close to 0, but all the rounding is still biased away from 0. If you are inclined to tackle this you could instead round halves toward the nearest even integer (often referred to as stats rounding or banker's rounding), and we can tweak our definition as follows:

For $d \in \mathbb Z$, let $R_d:\mathbb R \rightarrow \mathbb Z$ such that $$R_d(x) = \begin{cases} \dfrac{\lfloor10^d x + 0.5\rfloor}{10^d}, &x\text{ is nonnegative and }\lfloor10^d x\rfloor\text{ is odd}\\ \dfrac{\lfloor10^d x - 0.5\rfloor}{10^d}, &x\text{ is nonnegative and }\lfloor10^dx\rfloor\text{is even}\\ \dfrac{\lceil10^d x - 0.5\rceil}{10^d}, &x\text{ is negative and }\lceil10^dx\rceil\text{ is odd}\\ \dfrac{\lceil10^d x + 0.5\rceil}{10^d}, &x\text{ is negative and }\lceil10^dx\rceil\text{ is even} \end{cases}$$

Now you've eliminated the bias away from 0, but you're left with micro-biases toward even numbers compared to odd numbers. We could go on an on with different tweaks and variations on rounding, but the bottom line is that you will want to define a method of rounding that is most suitable for the task at hand, and then make sure that you clearly communicate that method of rounding and perhaps even include analysis of its desired advantages and known disadvantages for your particular application.