The Sinister Design Forums

General => General Discussion => Topic started by: Ertxiem on February 07, 2020, 05:31:31 PM

Title: Rounding numbers
Post by: Ertxiem on February 07, 2020, 05:31:31 PM
While reading the post regarding rounding of numbers:
[...]
-- fixed: Unity was rounding 0.5 down to 0 instead of up to 1, which is apparently because Mathf.RoundToInt() just uses C#'s default rounding (https://forum.unity.com/threads/mathf-roundtoint.491182/), which was designed for banks and not for games.
I recalled that I learned in school the rule to round to the nearest number, with ties going to the even number. I used it in Physics, Chemistry and Statistics.

Curiosity drove me to take a look at Wikipedia. I was able to find that the reported oldest recommendation of rounding to the nearest number, with ties going to the even number was in a book from 1906 (https://en.wikipedia.org/wiki/Rounding#History). Several names are being used for this type of rounding: convergent rounding, statistician's rounding, Dutch rounding, Gaussian rounding, odd–even rounding, or bankers' rounding (this last term having a bit obscure origin, since there is no strong reference about banks using it).
Title: Re: Rounding numbers
Post by: CraigStern on February 09, 2020, 12:00:15 PM
That's interesting! In school, I was taught that ties always round upwards (away from 0), which is actually quite commonplace (http://mathforum.org/library/drmath/view/63989.html) (and at least in this article (https://www.mathsisfun.com/numbers/rounding-methods.html), referred to as "the common method"). I wasn't even aware that other round methods for x.5 values existed until the other day!