Stack Exchange
Stack Overflow
Questions
Tags
Users
About
Stack Overflow
Public
Questions
Tags
Users
About
why rounding 100 * 0.575 is not the same as rounding 57.5?
Asked
May 23 '22 at 11:12
Active
May 23 '22 at 11:13
Viewed
43 times
-1
System.Math.Round(57.5);
58.0
System.Math.Round(0.575 *100);
57.0
System.Math.Round(0.775*100);
78.0
c#
edited May 23 '22 at 11:13
Lee Taylor
7,155
14
29
44
asked May 23 '22 at 11:12
shmulikg
9
3
https://en.wikipedia.org/wiki/Floating-point_arithmetic
–
nbokmans
May 23 '22 at 11:14
If you check you'll see that `0.575 * 100` results in `57.49999999999999` because floating point numbers are not precise. However if you use decimal `0.575M * 100` then it is `57.5` and rounds as expected.
–
juharr
May 23 '22 at 11:37
0 Answers
0