Member-only story

šŸ˜µā€šŸ’« 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
Tom Smykowski

Written by Tom Smykowski

šŸš€ Senior/Lead Frontend Engineer | Angular Ā· Vue.js Ā· React | Design Systems, UI/UX | Looking for a new project! šŸ“© contact@tomasz-smykowski.com

Responses (1)