Month: January 2019
After discussing the subject of my previous CodeProject publication with others, I got curious how other languages handle the mid point values. I was happily surprised that almost every language did have this subject covered. However, there are a lot of differences between languages.
To hopefully help someone in the future, I have mapped the rounding methods in a table. X’s in bold are default implementations, other X’s are optional parameters or separate methods.
The language names in the table link to the documentation I used.
Without further ado, the big “programming language/rounding method table”:
* The table references Python 3.7 but Python 2 actually has a different round implementation. It will round half away form zero.
** The mode keywords in Ruby are
:up for “round half away from zero” and
:down for “round half towards zero”, making them quite confusing in my opinion.
Of course, I’ve added this table to the article as well. Check it out here: