Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
System.Math.Round
Message
 
To
10/07/2006 14:27:18
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01135065
Message ID:
01135072
Views:
10
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
Map
View

Click here to load this message in the networking platform