System Namespace Math Class
Returns the whole number nearest the specified value.
[ VB ]
Overloads Public Shared Function Round ( _
ByVal d As Decimal _
) As Decimal
[ C# ]
public static decimal Round (
decimal d
);
[ C++ ]
public: static Decimal Round (
Decimal d
);
[ JScript ]
public static function Round (
d : Decimal
) : Decimal;
- d
- A Decimal number to be rounded.
The whole number nearest parameter d. 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.
[ Visual Basic, C#, C++ ] The following code example demonstrates rounding to nearest.
[ VB ]
Math.Round ( 4.4 ) 'Returns 4.0.
Math.Round ( 4.5 ) 'Returns 4.0.
Math.Round ( 4.6 ) 'Returns 5.0.
[ C# ]
Math.Round ( 4.4 ); //Returns 4.0.
Math.Round ( 4.5 ); //Returns 4.0.
Math.Round ( 4.6 ); //Returns 5.0.
[ C++ ]
Math::Round ( 4.4 ); //Returns 4.0.
Math::Round ( 4.5 ); //Returns 4.0.
Math::Round ( 4.6 ); //Returns 5.0.
Math Members Math.Round Overload List Ceiling Floor