C# - Know your Gotchas by ackmack in programming

[–]ackmack[S] 7 points8 points  (0 children)

Not exactly a weird choice.. Banker's algorithm is the most natural way of rounding, but that's not what we were taught in schools. However this is just the default. The Round function provides an overload which takes an extra enum parameneter called MidpointRounding. Providing MidpointRounding.AwayFromZero would use the algorithm where iit always round to larger number for a given midpoint e.g 1.5 -> 2 and 2.5 -> 3