# šµāš« There Is No One Rounding StandardĀ InĀ Programming

# If you will round a half, you will get different result depending on your programming language.

Coding in multiple programming languages gives you a better understanding of how things can be done.

Today I will tell you about something you donāt know about rounding numbers. I am sure you donāt know it, because I am programming for 20 years now, and didnāt know it either.

If you, however, by any chance know it, you can tap you on your shoulder, because like one on 100k developers knows it I guess.

# Rounding

Rounding is a basic mathematical concept that we all know, there is no surprise there. 1.1 becomes 1, 2.7 becomes 3. The trouble begins when you have to round a half of a number, for example 2.5.

Should you round it to 2, or to 3? I donāt know about you, but for me the answer is obvious: round it to three.

Interestingly enough, there are many other ways to round a number. Here is an illustration from the Wikipedia page:

So, you can round 2.5 up to 3, you can round it down obtaining 2. You can even round it to even number (2) or odd number (3).

For some mathematical calculations including sums the way to round numbers is important.

For example if you have ten 2.5 numbers, and you will round them up, and then sum the results, you will get a sum of 30. While the not-rounded sum is 25. The resulting difference of five is caused by rounding up and canāt be always accepted.

On the other hand, if you round to an even or odd number, the difference between not rounded and rounded numbers is smaller for more random set of data.

As you can see, rounding is important.

With so many various methods of rounding you can use to achieve better results. Otherwise things can go very wrong like in Vancouver in 1982. The index of local Stock Exchange fell 50% in almost two years even while stock prices went up. Itā¦