Rounding Question

  • Thread starter Thread starter Samuel
  • Start date Start date
S

Samuel

The first line of code produces the value of 1.92 while the second 1.18

WHY???



Dim d As Double = Math.Round(1.925, 2)

Dim d1 As Double = Math.Round(1.175, 2)
 
The first line of code produces the value of 1.92 while the second 1.18

WHY???



Dim d As Double = Math.Round(1.925, 2)

Dim d1 As Double = Math.Round(1.175, 2)

Because the digit before the 5 in 1.925 is even, and the digit before
the 5 in 1.175 is odd.

See the Remarks section of the Math.Round documentation for details,
and for ways to control what kind of rounding is done.

<http://msdn2.microsoft.com/en-us/library/zy06z30k.aspx>
 
Back
Top