General information
Category:
Coding, syntax and commands
I would say, they in VB.NET do not follow the math rules. As in Net Help:
*----------------------------
The following code example demonstrates rounding to nearest.
[Visual Basic]
Math.Round(3.44, 1) 'Returns 3.4.
Math.Round(3.45, 1) 'Returns 3.4.
Math.Round(3.46, 1) 'Returns 3.5.
If d is halfway between two whole numbers, one of which by definition is even and the other odd, then the even number is returned.
The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding.
"rounding toward zero"
*------------------------------------------
However, rounding should go up in cases like 3.45,or 10.125 in pure math. Sure in banking they want to trick you and round you money to zero.
>I am having a problem with rounding in vb.net
>0.5 * 20.25 = 10.125
> in vb.net MsgBox(System.Math.Round(0.5 * 20.25, 2)) = 10.12
>in VFP ?round(.5 * 20.25,2) = 10.13
>
>What am I missing
>
>Thanks
>
>Paul
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only