I am using ROUND
function from C# and SQL, and surprisingly both are yielding different results.
In SQL: ROUND(1250.00, -2)
= 1300
In C# ROUND 1250
with round and precision = 2
= 1200
Has anyone came across this situation before?
C# uses banker's rounding by default, where when you're exactly on the .5 mark, it rounds to the nearest even number instead of always rounding up.
The remarks section of the msdn article describes this behavior. Basically it's to reduce rounding errors when you accumulate a lot of rounded numbers together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With