Floating-point APIs are being updated to comply with IEEE 754-2008 revision. The goal of these changes is to expose all required operations and ensure that they're behaviorally compliant with the IEEE spec.
In .NET Core 3.0, the following fixes are included related to parsing and formatting.
The following new System.Math
APIs are also included.
BitIncrement(Double) and BitDecrement(Double)
Corresponds to the nextUp
and nextDown
IEEE operations.
Math.BitIncrement(0.0)
would return double.Epsilon
.MaxMagnitude(Double, Double) and MinMagnitude(Double, Double)
Corresponds to the maxNumMag
and minNumMag
IEEE operations.
Math.MaxMagnitude(2.0, -3.0)
would return -3.0
.Corresponds to the logB
IEEE operation.
floor(log2(x))
, but done with a minimal rounding error.Corresponds to the scaleB
IEEE operation. It takes an integral value, it returns effectively x * pow(2, n)
, but is done with a minimal rounding error.
Corresponds to the log2
IEEE operation, it returns the base-2 logarithm. It minimizes rounding errors.
FusedMultiplyAdd(Double, Double, Double)
Corresponds to the fma
IEEE operation.
(x * y) + z
as a single operation, thereby minimizing the rounding error.FusedMultiplyAdd(1e308, 2.0, -1e308)
, which returns 1e308
.(1e308 * 2.0) - 1e308
returns double.PositiveInfinity
.Corresponds to the copySign
IEEE operation, it returns the value of x
, but with the sign of y
.