You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System/Math.xml
+2-14Lines changed: 2 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -6664,15 +6664,12 @@ The following example illustrates the problem. It repeatedly adds .1 to 11.0 and
6664
6664
Problems of precision in rounding midpoint values are most likely to arise in the following conditions:
6665
6665
6666
6666
- When a fractional value cannot be expressed precisely in the floating-point type's binary format.
6667
-
6668
6667
- When the value to be rounded is calculated from one or more floating-point operations.
6669
-
6670
6668
- When the value to be rounded is a <xref:System.Single> rather than a <xref:System.Double> or <xref:System.Decimal>. For more information, see the next section, [Rounding and single-precision floating-point values](#rounding-and-single-precision-floating-point-values).
6671
6669
6672
-
In cases where the lack of precision in rounding operations is problematic, you can do the following:
6670
+
In cases where the lack of precision in rounding operations is problematic, you can do the following:
6673
6671
6674
6672
- If the rounding operation calls an overload that rounds a <xref:System.Double> value, you can change the <xref:System.Double> to a <xref:System.Decimal> value and call an overload that rounds a <xref:System.Decimal> value instead. Although the <xref:System.Decimal> data type also has problems of representation and loss of precision, these issues are far less common.
6675
-
6676
6673
- Define a custom rounding algorithm that performs a "nearly equal" test to determine whether the value to be rounded is acceptably close to a midpoint value. The following example defines a `RoundApproximate` method that examines whether a fractional value is sufficiently near to a midpoint value to be subject to midpoint rounding. As the output from the example shows, it corrects the rounding problem shown in the previous example.
@@ -6693,16 +6690,7 @@ In many cases, as the example illustrates, the loss of precision can be minimize
6693
6690
6694
6691
## Examples
6695
6692
6696
-
In addition to the examples in the [Remarks](#remarks-round) section, this article includes examples that illustrate the following overloads of the `Math.Round` method:
0 commit comments