# 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. – Paul Sinclair 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 – Ivo Beckers 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. – richard1941 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.. – Paul Sinclair Sep 18 '19 at 3:30
• @Paul Sinclair. I apologize. Certainly a very, very common practice in the real world must be right. – richard1941 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. – The_Sympathizer Sep 13 '19 at 0:47
• Exactly, I now prefer the other one now – Rayreware Sep 13 '19 at 10:02
• $\lfloor x \rceil$ is highly used in modern Cryptography. – kelalaka 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. – chepner Sep 14 '19 at 22:16
• I cannot find such a notation on Wikipedia. Could anyone give a more precise link? Thanks! – Cm7F7Bb yesterday

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. – leftaroundabout 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. – Arthur 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. – Carl Witthoft 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]$. – leftaroundabout 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") – Monty Harder Sep 12 '19 at 20:04
• And some implementations are not clear if they round down or towards zero for negative numbers. – KalleMP Sep 12 '19 at 20:56
• – Acccumulation 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. – Especially Lime Sep 13 '19 at 7:16
• @MontyHarder: Both of those are bad (introduce bias). – R.. GitHub STOP HELPING ICE 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. – Eric Towers 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$$