Skip to content

Commit f7b441d

Browse files
author
Prashanth Govindarajan
authored
Add explicit APIs to Double/Single/Half/TimeOnly (#58774)
* Add explicit APIs to Double/Single/Half/TimeOnly * sq * Fix get accessor in ref
1 parent 67354a2 commit f7b441d

5 files changed

Lines changed: 136 additions & 0 deletions

File tree

src/libraries/System.Private.CoreLib/src/System/Double.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,30 @@ static double IFloatingPoint<double>.Tanh(double x)
756756
static double IFloatingPoint<double>.Truncate(double x)
757757
=> Math.Truncate(x);
758758

759+
[RequiresPreviewFeatures]
760+
static bool IFloatingPoint<double>.IsFinite(double d) => IsFinite(d);
761+
762+
[RequiresPreviewFeatures]
763+
static bool IFloatingPoint<double>.IsInfinity(double d) => IsInfinity(d);
764+
765+
[RequiresPreviewFeatures]
766+
static bool IFloatingPoint<double>.IsNaN(double d) => IsNaN(d);
767+
768+
[RequiresPreviewFeatures]
769+
static bool IFloatingPoint<double>.IsNegative(double d) => IsNegative(d);
770+
771+
[RequiresPreviewFeatures]
772+
static bool IFloatingPoint<double>.IsNegativeInfinity(double d) => IsNegativeInfinity(d);
773+
774+
[RequiresPreviewFeatures]
775+
static bool IFloatingPoint<double>.IsNormal(double d) => IsNormal(d);
776+
777+
[RequiresPreviewFeatures]
778+
static bool IFloatingPoint<double>.IsPositiveInfinity(double d) => IsPositiveInfinity(d);
779+
780+
[RequiresPreviewFeatures]
781+
static bool IFloatingPoint<double>.IsSubnormal(double d) => IsSubnormal(d);
782+
759783
// static double IFloatingPoint<double>.AcosPi(double x)
760784
// => Math.AcosPi(x);
761785
//

src/libraries/System.Private.CoreLib/src/System/Half.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,31 @@ static Half IFloatingPoint<Half>.Tanh(Half x)
10591059
static Half IFloatingPoint<Half>.Truncate(Half x)
10601060
=> (Half)MathF.Truncate((float)x);
10611061

1062+
[RequiresPreviewFeatures]
1063+
static bool IFloatingPoint<Half>.IsFinite(Half x) => IsFinite(x);
1064+
1065+
[RequiresPreviewFeatures]
1066+
static bool IFloatingPoint<Half>.IsInfinity(Half x) => IsInfinity(x);
1067+
1068+
[RequiresPreviewFeatures]
1069+
static bool IFloatingPoint<Half>.IsNaN(Half x) => IsNaN(x);
1070+
1071+
[RequiresPreviewFeatures]
1072+
static bool IFloatingPoint<Half>.IsNegative(Half x) => IsNegative(x);
1073+
1074+
[RequiresPreviewFeatures]
1075+
static bool IFloatingPoint<Half>.IsNegativeInfinity(Half x) => IsNegativeInfinity(x);
1076+
1077+
[RequiresPreviewFeatures]
1078+
static bool IFloatingPoint<Half>.IsNormal(Half x) => IsNormal(x);
1079+
1080+
[RequiresPreviewFeatures]
1081+
static bool IFloatingPoint<Half>.IsPositiveInfinity(Half x) => IsPositiveInfinity(x);
1082+
1083+
[RequiresPreviewFeatures]
1084+
static bool IFloatingPoint<Half>.IsSubnormal(Half x) => IsSubnormal(x);
1085+
1086+
10621087
// static Half IFloatingPoint<Half>.AcosPi(Half x)
10631088
// => (Half)MathF.AcosPi((float)x);
10641089
//

src/libraries/System.Private.CoreLib/src/System/Single.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,30 @@ static float IFloatingPoint<float>.Tanh(float x)
748748
static float IFloatingPoint<float>.Truncate(float x)
749749
=> MathF.Truncate(x);
750750

751+
[RequiresPreviewFeatures]
752+
static bool IFloatingPoint<float>.IsFinite(float x) => IsFinite(x);
753+
754+
[RequiresPreviewFeatures]
755+
static bool IFloatingPoint<float>.IsInfinity(float x) => IsInfinity(x);
756+
757+
[RequiresPreviewFeatures]
758+
static bool IFloatingPoint<float>.IsNaN(float x) => IsNaN(x);
759+
760+
[RequiresPreviewFeatures]
761+
static bool IFloatingPoint<float>.IsNegative(float x) => IsNegative(x);
762+
763+
[RequiresPreviewFeatures]
764+
static bool IFloatingPoint<float>.IsNegativeInfinity(float x) => IsNegativeInfinity(x);
765+
766+
[RequiresPreviewFeatures]
767+
static bool IFloatingPoint<float>.IsNormal(float x) => IsNormal(x);
768+
769+
[RequiresPreviewFeatures]
770+
static bool IFloatingPoint<float>.IsPositiveInfinity(float x) => IsPositiveInfinity(x);
771+
772+
[RequiresPreviewFeatures]
773+
static bool IFloatingPoint<float>.IsSubnormal(float x) => IsSubnormal(x);
774+
751775
// static float IFloatingPoint<float>.AcosPi(float x)
752776
// => MathF.AcosPi(x);
753777
//

src/libraries/System.Private.CoreLib/src/System/TimeOnly.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,13 @@ static bool ISpanParseable<TimeOnly>.TryParse(ReadOnlySpan<char> s, IFormatProvi
974974
// [RequiresPreviewFeatures]
975975
// static checked TimeSpan ISubtractionOperators<TimeOnly, TimeOnly, TimeSpan>.operator -(TimeOnly left, TimeOnly right)
976976
// => checked(left - right);
977+
978+
[RequiresPreviewFeatures]
979+
static TimeOnly IMinMaxValue<TimeOnly>.MinValue => MinValue;
980+
981+
[RequiresPreviewFeatures]
982+
static TimeOnly IMinMaxValue<TimeOnly>.MaxValue => MaxValue;
983+
977984
#endif // FEATURE_GENERIC_MATH
978985
}
979986
}

src/libraries/System.Runtime/ref/System.Runtime.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,6 +2552,23 @@ public DivideByZeroException(string? message, System.Exception? innerException)
25522552
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
25532553
static double IFloatingPoint<double>.Truncate(double x) { throw null; }
25542554

2555+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2556+
static bool IFloatingPoint<double>.IsFinite(double d) { throw null; }
2557+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2558+
static bool IFloatingPoint<double>.IsInfinity(double d) { throw null; }
2559+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2560+
static bool IFloatingPoint<double>.IsNaN(double d) { throw null; }
2561+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2562+
static bool IFloatingPoint<double>.IsNegative(double d) { throw null; }
2563+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2564+
static bool IFloatingPoint<double>.IsNegativeInfinity(double d) { throw null; }
2565+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2566+
static bool IFloatingPoint<double>.IsNormal(double d) { throw null; }
2567+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2568+
static bool IFloatingPoint<double>.IsPositiveInfinity(double d) { throw null; }
2569+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
2570+
static bool IFloatingPoint<double>.IsSubnormal(double d) { throw null; }
2571+
25552572
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
25562573
static double IIncrementOperators<double>.operator ++(double value) { throw null; }
25572574

@@ -3269,6 +3286,23 @@ public GopherStyleUriParser() { }
32693286
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
32703287
static System.Half IFloatingPoint<System.Half>.Truncate(System.Half x) { throw null; }
32713288

3289+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3290+
static bool IFloatingPoint<System.Half>.IsFinite(System.Half x) { throw null; }
3291+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3292+
static bool IFloatingPoint<System.Half>.IsInfinity(System.Half x) { throw null; }
3293+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3294+
static bool IFloatingPoint<System.Half>.IsNaN(System.Half x) { throw null; }
3295+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3296+
static bool IFloatingPoint<System.Half>.IsNegative(System.Half x) { throw null; }
3297+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3298+
static bool IFloatingPoint<System.Half>.IsNegativeInfinity(System.Half x) { throw null; }
3299+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3300+
static bool IFloatingPoint<System.Half>.IsNormal(System.Half x) { throw null; }
3301+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3302+
static bool IFloatingPoint<System.Half>.IsPositiveInfinity(System.Half x) { throw null; }
3303+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
3304+
static bool IFloatingPoint<System.Half>.IsSubnormal(System.Half x) { throw null; }
3305+
32723306
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
32733307
static System.Half IIncrementOperators<System.Half>.operator ++(System.Half value) { throw null; }
32743308

@@ -5594,6 +5628,23 @@ public SerializableAttribute() { }
55945628
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
55955629
static float IFloatingPoint<float>.Truncate(float x) { throw null; }
55965630

5631+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5632+
static bool IFloatingPoint<float>.IsFinite(float x) { throw null; }
5633+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5634+
static bool IFloatingPoint<float>.IsInfinity(float x) { throw null; }
5635+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5636+
static bool IFloatingPoint<float>.IsNaN(float x) { throw null; }
5637+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5638+
static bool IFloatingPoint<float>.IsNegative(float x) { throw null; }
5639+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5640+
static bool IFloatingPoint<float>.IsNegativeInfinity(float x) { throw null; }
5641+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5642+
static bool IFloatingPoint<float>.IsNormal(float x) { throw null; }
5643+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5644+
static bool IFloatingPoint<float>.IsPositiveInfinity(float x) { throw null; }
5645+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
5646+
static bool IFloatingPoint<float>.IsSubnormal(float x) { throw null; }
5647+
55975648
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
55985649
static float IIncrementOperators<float>.operator ++(float value) { throw null; }
55995650

@@ -6062,6 +6113,11 @@ public ThreadStaticAttribute() { }
60626113

60636114
[System.Runtime.Versioning.RequiresPreviewFeatures]
60646115
static System.TimeSpan ISubtractionOperators<System.TimeOnly, System.TimeOnly, System.TimeSpan>.operator -(System.TimeOnly left, System.TimeOnly right) { throw null; }
6116+
6117+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
6118+
static System.TimeOnly IMinMaxValue<System.TimeOnly>.MinValue { get { throw null; } }
6119+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
6120+
static System.TimeOnly IMinMaxValue<System.TimeOnly>.MaxValue { get { throw null; } }
60656121
#endif // FEATURE_GENERIC_MATH
60666122
}
60676123
public partial class TimeoutException : System.SystemException

0 commit comments

Comments
 (0)