asp.net.ph

Math.Round Method ( Double )

System Namespace   Math Class


Returns the whole number nearest the specified value.

[ VB ]
Overloads Public Shared Function Round ( _
   ByVal a As Double _
) As Double

[ C# ]
public static double Round (
   double a
);

[ C++ ]
public: static double Round (
   double a
);

[ JScript ]
public static function Round (
   a : double
) : double;

Parameters

a
A double-precision floating-point number to be rounded.

Return Value

The whole number nearest a. If a is halfway between two whole numbers, one of which by definition is even and the other odd, then the even number is returned.

Remarks

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.

Example

[ 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.
See Also

Math Members   Math.Round Overload List   Ceiling   Floor Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph