đŸ˜”â€đŸ’« There Is No One Rounding Standard In Programming

Tom Smykowski
4 min readJan 27, 2023

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:

--

--

Tom Smykowski

Software Engineer & Tech Editor. Top 2% on StackOverflow, 3mil views on Quora. Won Shattered Pixel Dungeon.