.NET Framework Class Library
Math..::.Round Method

Rounds a value to the nearest integer or specified number of decimal places.

Overload List

  NameDescription
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkRound(Decimal)Rounds a decimal value to the nearest integral value.
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkRound(Double)Rounds a double-precision floating-point value to the nearest integral value.
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkRound(Decimal, Int32)Rounds a decimal value to a specified number of fractional digits.
Public methodStatic memberRound(Decimal, MidpointRounding)Rounds a decimal value to the nearest integer. A parameter specifies how to round the value if it is midway between two other numbers.
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkRound(Double, Int32)Rounds a double-precision floating-point value to a specified number of fractional digits.
Public methodStatic memberRound(Double, MidpointRounding)Rounds a double-precision floating-point value to the nearest integer. A parameter specifies how to round the value if it is midway between two other numbers.
Public methodStatic memberRound(Decimal, Int32, MidpointRounding)Rounds a decimal value to a specified number of fractional digits. A parameter specifies how to round the value if it is midway between two other numbers.
Public methodStatic memberRound(Double, Int32, MidpointRounding)Rounds a double-precision floating-point value to the specified number of fractional digits. A parameter specifies how to round the value if it is midway between two other numbers.
Top
See Also

Reference

Tags :


Community Content

DoomGoober
Default Rounding Method
By default, Math.Round uses MidpointRounding.ToEven. Most people are not familiar with "rounding to even" as the alternative, "rounding away from zero" is more commonly taught in school. .NET defaults to "Rounding to even" as it is statistically superior because it doesn't share the tendency of "rounding away from zero" to round up slightly more often than it rounds down (assuming the numbers being rounded tend to be positive.)

Page view tracker