i have a problem in this query
select 7.115 + 2.885
result is 10.000
versus this query
select round(7.115,2) + round(2.885,2)
result of it is 10.010
i wonder how to make it correct.
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.
It is already correct. When you round it to 2 places, in both cases it is (correctly) being rounding up by effectively adding
0.005. The sum of these two rounding deltas is0.01so the result being10.01is as expected.There is nothing to “fix” here – it is behaving correctly and as expected.
If you mean “how do I make it display
10.00as the result of the addition”, do this: