-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
dotnet/coreclr
#20788Closed
Copy link
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
Rationale
The IEEE 754:2008 spec lists a number of required operations. We should expose the missing operations to be more compliant and to give users the greatest flexibility when writing their applications.
NOTE: This does not represent all missing operations, but rather a smaller batch of operations that should be reasonable to review. The full set of missing operations is covered in https://github.com/dotnet/corefx/issues/31901
Proposed API
public partial static class Math
{
public static double BitIncrement(double); // IEEE `nextUp`, C `nextafter` - The smallest value such that `result > x`
public static double BitDecrement(double); // IEEE `nextDown` - The smallest value such that `result < x`
public static double MaxMagnitude(double, double); // IEEE `minNumMag` - `x` if `Abs(x) > Abs(y)`; `y` if `Abs(y) > Abs(x)`; otherwise `Max(x, y)`
public static double MinMagnitude(double, double); // IEEE `maxNumMag` - `x` if `Abs(x) < Abs(y)`; `y` if `Abs(y) < Abs(x)`; otherwise `Min(x, y)`
public static int ILogB(double); // IEEE `logB`, C `ilogb` - Equivalent to `(int)Math.Log2(x)`
public static double ScaleB(double, int); // IEEE `scaleB`, C `scalbn` - Equivalent to `x * 2^n`
public static double Log2(double); // IEEE `logB`, C `logb` or `log2`
public static double ScaleB(double, double); // IEEE `scaleB`, C `scalbn` - Equivalent to `x * 2^n`
public static double FusedMultiplyAdd(double, double, double); // IEEE `fusedMultiplyAdd`, C `fma`
public static double CopySign(double, double); // IEEE `copySign`, C `copysign` - Exposed internally as `Math.copysign`
}
public partial static class MathF
{
public static float BitIncrement(float); // IEEE `nextUp`, C `nextafterf` - The smallest value such that `result > x`
public static float BitDecrement(float); // IEEE `nextDown` - The smallest value such that `result < x`
public static float MaxMagnitude(float, float); // IEEE `minNumMag` - `x` if `Abs(x) > Abs(y)`; `y` if `Abs(y) > Abs(x)`; otherwise `Max(x, y)`
public static float MinMagnitude(float, float); // IEEE `maxNumMag` - `x` if `Abs(x) < Abs(y)`; `y` if `Abs(y) < Abs(x)`; otherwise `Min(x, y)`
public static int ILogB(float); // IEEE `logB`, C `ilogbf` - Equivalent to `(int)MathF.Log2(x)`
public static float ScaleB(float, int); // IEEE `scaleB`, C `scalbnf` - Equivalent to `x * 2^n`
public static float Log2(float); // IEEE `logB`, C `logbf` or `log2f`
public static float ScaleB(float, float); // IEEE `scaleB`, C `scalbnf` - Equivalent to `x * 2^n`
public static float FusedMultiplyAdd(float, float, float); // IEEE `fusedMultiplyAdd`, C `fmaf`
public static float CopySign(float, float); // IEEE `copySign`, C `copysignf` - Exposed internally as `MathF.copysign`
}saucecontrol, jnm2 and HFadeel
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors