Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 1.1
.NET Framework
Reference
System
Math Class
Methods
Round Method

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
.NET Framework Class Library
Math.Round Method

Returns the number nearest the specified value.

Overload List

Returns the whole number nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Decimal) As Decimal
[C#] public static decimal Round(decimal);
[C++] public: static Decimal Round(Decimal);
[JScript] public static function Round(Decimal) : Decimal;

Returns the whole number nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Double) As Double
[C#] public static double Round(double);
[C++] public: static double Round(double);
[JScript] public static function Round(double) : double;

Returns the number with the specified precision nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Decimal, Integer) As Decimal
[C#] public static decimal Round(decimal, int);
[C++] public: static Decimal Round(Decimal, int);
[JScript] public static function Round(Decimal, int) : Decimal;

Returns the number with the specified precision nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Double, Integer) As Double
[C#] public static double Round(double, int);
[C++] public: static double Round(double, int);
[JScript] public static function Round(double, int) : double;

Example

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.

[C#] 
Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.

[C++] 

Math::Round(3.44, 1); //Returns 3.4.
Math::Round(3.45, 1); //Returns 3.4.
Math::Round(3.46, 1); //Returns 3.5.

[JScript] 
System.Math.Round(3.44, 1) //Returns 3.4.
System.Math.Round(3.45, 1) //Returns 3.4.
System.Math.Round(3.46, 1) //Returns 3.5.

See Also

Math Class | Math Members | System Namespace

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker