# How do you mathematically round a number?

How does someone mathematically round a number to its nearest integer?

For example 1.2 would round down to 1 and 1.7 would round up to 2

-
Are you asking for an algorithm to round the number? – Chao Xu Jan 13 '11 at 18:37

You could use the "ceiling-function / floor-function" which always rounds an integer up/down ( http://en.wikipedia.org/wiki/Floor_and_ceiling_functions ).

If you want the number to be rounded the way you want you could just do

$\text{round}(x)= \lceil x-\frac{1}{2} \rceil$ Note that in this case $\text{round}(1.5)=1$

Or $\text{round'}(x)= \lfloor x+\frac{1}{2} \rfloor$ Note that in this case $\text{round'}(1.5)=2$

-
round' is what I was after. I didn't know that floor and ceiling functions exists in mathematical syntax – ParoX Jan 13 '11 at 18:46
@BHare: in «mathematical syntax» everything you can come up with exists. – Mariano Suárez-Alvarez Jan 14 '11 at 0:39

This is equivalent to looking at the floor and ceiling functions. See this. In particular, rounding a number $y$ to an integer $q$ is the same thing as looking as $q = \text{floor}(y)$ or $q = \text{ceil}(y)$.

-