Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
System
Math Class
Math Methods
Round Method
Collapse All/Expand All Collapse All
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
.NET Framework Class Library
Math..::.Round Method

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

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  NameDescription
Public methodStatic memberRound(Decimal)Rounds a decimal value to the nearest integral value.
Public methodStatic memberRound(Double)Rounds a double-precision floating-point value to the nearest integral value.
Public methodStatic memberRound(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 memberRound(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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
You would think the most common rounding method would be default      Matt Olson ... R Petrusha - MSFT   |   Edit   |   Show History

The documentation states that symetric arthimetic rounding is the most common rounding method used in the world, but yet the default is bankers rounding. Who the heck decided that bankers rounding should be the default!??!

When I want 74.5 to round to 75, I have to use MidpointRounding.AwayFromZero. Why isn't AwayFromZero the default? Why did you choose a much less common rounding method (Bankers rounding) as the default!?

Why Bankers Rounding?

A major consequence of rounding, of course, is that the rounded data is lost. When those rounded values are used susequently in other numeric or statistical operations, the rounding operation itself can affect the outcome of the operation. If the rounding method being used introduces a bias, the result of a operation can be statistically significant solely because of the method of rounding that was employed.

Depending on the data set, symmetric arithmetic rounding can introduce a major bias, since it always rounds midpoint values upward. To take a simple example, suppose that we want to determine the mean of three values, 1.5, 2.5, and 3.5, but that we want to first round them to the nearest integer before calculating their mean. Note that the true mean of these values is is 2.5. Using symmetic arithmetic rounding, these values change to 2, 3, and 4, and their mean is 3. Using bankers rounding, these values change to 2, 2, and 4, and their mean is 2.67. Because the latter rounding method is much closer to the true mean of the three values, it provides the least loss of data.

In a nutshell, we've chosen banker's rounding rather than the more commonly used symmetic arithmetic rounding because it more closely preserves the unrounded value when that value may be used in subsequent arithmetic operations.

I hope that this helps to answer your question.

--Ron Petrusha
Common Language Runtime Developer Content
Microsoft Corporation

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker