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

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.

• There are many common operations that do not have a widely agreed on standard notation. For various reasons, rounding is among them. In these cases you can use whatever notation you want. You just have to explain the notation when you introduce it. In this case, part of what you should explain is which rules of rounding you are using, as "nearest integer" is ambiguous when the value is halfway between two integers. Rounding $0.5$ up is commonly thought of, but causes bias when used on large datasets. Rounding $n.5$ to the nearest even integer is commonly used to avoid that bias. Sep 12 '19 at 16:58
• I'm not a mathematician so I don't know what is common and won't post this as an answer but I think just writing $\lfloor x + 0.5\rfloor$ might work Sep 13 '19 at 7:34
• @Paul Sinclair, it depends on what statistic will have the bias. For a statistic that is the product of all the numbers, rounding 0.5 to the nearest even number would be absolute disaster. Sep 18 '19 at 2:36
• @richard1941 - You appear to have completely missed the point of my remark, which was to give an example of why "rounding to the nearest integer" is ambiguous, thus supporting the point that when discussing rounding, one should be clear about what rules you are following. Rounding to even is a very, very common practice in real world applications, which commonly sum large datasets, but almost never multiply them.. Sep 18 '19 at 3:30
• @Paul Sinclair. I apologize. Certainly a very, very common practice in the real world must be right. Sep 19 '19 at 5:47

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.

• Trouble with $[x]$ is that with any somewhat-complicated expression in the middle it runs the risk of being confused with ordinary square brackets. Sep 13 '19 at 0:47
• Exactly, I now prefer the other one now Sep 13 '19 at 10:02
• $\lfloor x \rceil$ is highly used in modern Cryptography. Sep 14 '19 at 18:49
• Isn't $[x]$ commonly used to represent the integer part of x, (i.e., round towards 0)? That's different from the usage proposed here if x is negative. Sep 14 '19 at 22:16
• The article I linked to was merged into another in November, and things were lost in the process. It is still in the revision history: en.wikipedia.org/w/… Feb 20 '20 at 8:16

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.

• Please, please don't use simple square brackets for rounding. They are already used for far too many other things. Sep 13 '19 at 9:43
• @leftaroundabout That depends entirely on what you're currently doing. Most uses are limited to a specific field of study. Also, there are only so many readily-available notations one can use, and square brackets get the job done. I have seen it used many times, and I have only gotten confused when they've been used to denote the floor function without adequately clarifying that fact. Sep 13 '19 at 10:11
• Please never use the "round-up for .5" rule. It introduces a bias in your data. Use the rule to round to the nearest even (or odd, doesn't really matter) integer. Sep 13 '19 at 11:27
• @Arthur limited to a specific field or not, it's still better to avoid using the same notation for different purposes. Your writing may be mostly intended for people from the same field, but you should still not make it more difficult than necessary for experts from other branches. That's especially true for something as hard to look up as some flavour of brackets. The exception is if you have lots and lots of these in your calculations and thus space is at a premium, but in that case $\lfloor\cdot\rceil$ is just as fine as $[\cdot]$. Sep 13 '19 at 11:53

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.)

• In some implementations, $[-1.5] = -1$ ("round exact half-integers up") and in others, $[-1.5] = -2$ ("round exact half-integers away from zero") Sep 12 '19 at 20:04
• And some implementations are not clear if they round down or towards zero for negative numbers. Sep 12 '19 at 20:56
• Sep 12 '19 at 21:42
• Yes,"banker's rounding" is the default in recent versions of python. The difference between "towards infinity" and "away from zero" is less critical because in many cases you're working in a context where everything is non-negative and can ignore that distinction. Sep 13 '19 at 7:16
• @MontyHarder: Both of those are bad (introduce bias). Sep 14 '19 at 16:26

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”.

• I prefer this notation, but the ambiguity of "round" is perhaps much greater than you suggest (and you have not minimized the ambiguity). I've worked with round up, round down, round towards zero, round away from zero, round half up, round half down, round half toward zero, round half away from zero, round half to even, round half to odd, round half alternating, round half randomly, round randomly, and many more variants. Sep 13 '19 at 13:58

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$$).

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.

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$$

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.