Rounding

1 comments

This may seem kind of obvious but in actual fact there are a couple of types of rounding, and there are lots of sites out there that explain it, but I'm going to keep it real simple here.

 

Normal rounding:

3.4 -> 3

3.5 -> 4

3.6 -> 4

 

Round-to-even method

(also known as unbiased rounding, convergent rounding, statistician's rounding, Dutch rounding, Gaussian rounding, or bankers' rounding)

 

exactly the same as above EXCEPT for numbers ending in 5

 

3.5 -> 4

4.5 -> 4 !!! this one went down because the number before the 5 was even (4 is an even number)

 

The reason for this crazy rounding is that it's better for statistics where you have heaps of numbers. Too much "normal" up-rounding skews datasets upwards. For more info check out: http://en.wikipedia.org/wiki/Rounding

 

 

Programming

C# Math.Round uses the Round-to-even method WATCH OUT http://msdn.microsoft.com/en-us/library/zy06z30k.aspx

 

Try using this instead Convert.ToDecimal(ourDecimalVariable.ToString("0.00"))


Comments


Leave a Comment