Our Web Engineer Reports:
Var num = “11.925”
Num.toFixed(2) will give you 11.93
In PHP you round like so:
echo round(num, 2) will give you 11.93
In VB.NET you round like so:
Dim num as Decimal = 11.925
Math.Round(num, 2) will give you 11.92….
All microsoft’s built in round functions do “Bankers Rounding” it rounds to the nearest even number
Math.Round(11.925, 2) = 11.92
Math.Round(11.935,2) = 11.93
Why is this important? Well when you're writing a quoting system or something that integrates with oh, say an accounting package, the rounding of MONEY is imporatant and should be accurate.
Bankers Rounding eh? So this is where my money is going at the bank.
Other intersting links on this rounding technique:
This MS Blog: Fabulous Adventures in Coding
Wikipedia: The round-to-even rounding rule