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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.