Share via


Round Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Rounds a double-precision floating-point value to the nearest integral value.

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

Syntax

'Declaration
Public Shared Function Round ( _
    d As Double _
) As Double
public static double Round(
    double d
)
public:
static double Round(
    double d
)
static member Round : 
        d:float -> float 
public static function Round(
    d : double
) : double

Parameters

Return Value

Type: System. . :: . .Double
The integer nearest d. If the fractional component of d is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns a Double instead of an integral type.

Remarks

This method is equivalent to calling the Round(Double, MidpointRounding) method with a mode argument of MidpointRounding.ToEven. 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. It minimizes rounding errors that result from consistently rounding a midpoint value in a single direction.

To control the type of rounding used by the Round method, call the Math.Round(Double, MidpointRounding) overload.

If the value of d is Double..::..NaN, the method returns Double..::..NaN. If the value of d is Double..::..PositiveInfinity or Double..::..NegativeInfinity, the method returns Double..::..PositiveInfinity or Double..::..NegativeInfinity, respectively.

.NET Framework Security

See Also

Reference

Math Class

System Namespace