Math.Round Method (Double, Int32)

Rounds a double-precision floating-point value to the specified precision.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static double Round (
	double value,
	int digits
public static double Round (
	double value, 
	int digits
public static function Round (
	value : double, 
	digits : int
) : double



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


The number of significant digits (precision) in the return value.

Return Value

The number nearest value with a precision equal to digits. If value is halfway between two numbers, one of which is even and the other odd, then the even number is returned. If the precision of value is less than digits, then value is returned unchanged.

Exception typeCondition


digits is less than 0 or greater than 15.

The digits parameter specifies the number of significant digits in the return value and ranges from 0 to 15. If digits is zero, then a integer is returned.

The maximum total number of integral and fractional digits that can be returned is 15. If the rounded value contains more than 15 digits, the 15 most significant digits are returned. If the rounded value contains 15 or fewer digits, the integral digits and as many fractional digits as the digits parameter specifies are 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.

The following example demonstrates rounding to nearest.

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

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.

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.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions