Thursday, November 8, 2007

Bankers Rounding confusion

The default behavior of Cint and Math.Round (not overloaded) in ASP.Net VB is rounding toward the even number "Bankers" rounding. Through normal life experience I thought rounding up was the common method. This threw me for a short loop while trying to calculate a value by adding and subtracting ratios of rounded numbers. I always check my work when dealing with calculations. In this case I was using Excel to check my work which apparently uses a different algorithm. I was not dealing with very many different combinations of rounded numbers so the discrepancy was difficult to find.

A facinating article detailing the different types of rounding is Wikipedia Bankers Rounding. I am a software developer/engineer which explains my use of the term "facinating" to describe an article about rounding numbers.