From 3798b2f0b18ff9110786ae5a4a900e27edaf712b Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 23 Nov 2021 09:22:52 -0800 Subject: [PATCH 01/16] Adding an INumberBase interface to the generic math proposal --- accepted/2021/statics-in-interfaces/README.md | 122 ++++++++++-------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index e82d89d98..390a0fbd4 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -196,14 +196,15 @@ interface "IModulusOperators" interface "IMultiplicativeIdentity" interface "IMultiplyOperators" interface "INumber" +interface "INumberBase" interface "IParseable" interface "ISerializable" interface "IShiftOperators" -interface "ISignedNumber" +interface "ISignedNumberBase" interface "ISpanFormattable" interface "ISpanParseable" interface "ISubtractionOperators" -interface "IUnsignedNumber" +interface "IUnsignedNumberBase" interface "IUnaryNegationOperators" interface "IUnaryPlusOperators" interface "IVector" @@ -223,39 +224,42 @@ interface "IVector" "IEquatable" <|-- "IEqualityOperators" -"ISignedNumber" <|-- "IFloatingPoint" +"ISignedNumberBase" <|-- "IFloatingPoint" -"IAdditionOperators" <|-- "INumber" -"IAdditiveIdentity" <|-- "INumber" "IComparisonOperators" <|-- "INumber" "IDecrementOperators" <|-- "INumber" "IDivisionOperators" <|-- "INumber" "IIncrementOperators" <|-- "INumber" "IModulusOperators" <|-- "INumber" "IMultiplicativeIdentity" <|-- "INumber" -"IMultiplyOperators" <|-- "INumber" +"INumberBase" <|-- "INumber" "ISpanFormattable" <|-- "INumber" "ISpanParseable" <|-- "INumber" -"ISubtractionOperators" <|-- "INumber" "IUnaryNegationOperators" <|-- "INumber" -"IUnaryPlusOperators" <|-- "INumber" -"INumber" <|-- "ISignedNumber" +"IAdditionOperators" <|-- "INumberBase" +"IAdditiveIdentity" <|-- "INumberBase" +"IEqualityOperators" <|-- "INumberBase" +"IMultiplyOperators" <|-- "INumberBase" +"ISubtractionOperators" <|-- "INumberBase" +"IUnaryPlusOperators" <|-- "INumberBase" + +"INumberBase" <|-- "ISignedNumberBase" "IFormattable" <|-- "ISpanFormattable" "IParseable" <|-- "ISpanParseable" -"INumber" <|-- "IUnsignedNumber" +"INumberBase" <|-- "IUnsignedNumberBase" "IAdditionOperators" <|-- "IVector" "IAdditiveIdentity" <|-- "IVector" "IBitwiseOperators" <|-- "IVector" "IComparisonOperators" <|-- "IVector" -"IDecrementOperators" <|-- "INumber" +"IDecrementOperators" <|-- "IVector" "IDivisionOperators" <|-- "IVector" -"IIncrementOperators" <|-- "INumber" -"IModulusOperators" <|-- "INumber" +"IIncrementOperators" <|-- "IVector" +"IModulusOperators" <|-- "IVector" "IMultiplicativeIdentity" <|-- "IVector" "IMultiplyOperators" <|-- "IVector" "ISpanFormattable" <|-- "IVector" @@ -296,13 +300,13 @@ class "Vector4" "IBinaryInteger" <|-- "Byte" "IConvertible" <|-- "Byte" "IMinMaxValue" <|-- "Byte" -"IUnsignedNumber" <|-- "Byte" +"IUnsignedNumberBase" <|-- "Byte" "ValueType" <|-- "Byte" "IBinaryInteger" <|-- "Char" "IConvertible" <|-- "Char" "IMinMaxValue" <|-- "Char" -"IUnsignedNumber" <|-- "Char" +"IUnsignedNumberBase" <|-- "Char" "ValueType" <|-- "Char" "IComparisonOperators" <|-- "DateOnly" @@ -337,7 +341,7 @@ class "Vector4" "IDeserializationCallback" <|-- "Decimal" "IMinMaxValue" <|-- "Decimal" "ISerializable" <|-- "Decimal" -"ISignedNumber" <|-- "Decimal" +"ISignedNumberBase" <|-- "Decimal" "ValueType" <|-- "Decimal" "IBinaryFloatingPoint" <|-- "Double" @@ -362,31 +366,31 @@ class "Vector4" "IBinaryInteger" <|-- "Int16" "IConvertible" <|-- "Int16" "IMinMaxValue" <|-- "Int16" -"ISignedNumber" <|-- "Int16" +"ISignedNumberBase" <|-- "Int16" "ValueType" <|-- "Int16" "IBinaryInteger" <|-- "Int32" "IConvertible" <|-- "Int32" "IMinMaxValue" <|-- "Int32" -"ISignedNumber" <|-- "Int32" +"ISignedNumberBase" <|-- "Int32" "ValueType" <|-- "Int32" "IBinaryInteger" <|-- "Int64" "IConvertible" <|-- "Int64" "IMinMaxValue" <|-- "Int64" -"ISignedNumber" <|-- "Int64" +"ISignedNumberBase" <|-- "Int64" "ValueType" <|-- "Int64" "IBinaryInteger" <|-- "IntPtr" "IMinMaxValue" <|-- "IntPtr" -"ISignedNumber" <|-- "IntPtr" +"ISignedNumberBase" <|-- "IntPtr" "ISerializable" <|-- "IntPtr" "ValueType" <|-- "IntPtr" "IBinaryInteger" <|-- "SByte" "IConvertible" <|-- "SByte" "IMinMaxValue" <|-- "SByte" -"ISignedNumber" <|-- "SByte" +"ISignedNumberBase" <|-- "SByte" "ValueType" <|-- "SByte" "IBinaryFloatingPoint" <|-- "Single" @@ -416,25 +420,25 @@ class "Vector4" "IBinaryInteger" <|-- "UInt16" "IConvertible" <|-- "UInt16" "IMinMaxValue" <|-- "UInt16" -"IUnsignedNumber" <|-- "UInt16" +"IUnsignedNumberBase" <|-- "UInt16" "ValueType" <|-- "UInt16" "IBinaryInteger" <|-- "UInt32" "IConvertible" <|-- "UInt32" "IMinMaxValue" <|-- "UInt32" -"IUnsignedNumber" <|-- "UInt32" +"IUnsignedNumberBase" <|-- "UInt32" "ValueType" <|-- "UInt32" "IBinaryInteger" <|-- "UInt64" "IConvertible" <|-- "UInt64" "IMinMaxValue" <|-- "UInt64" -"IUnsignedNumber" <|-- "UInt64" +"IUnsignedNumberBase" <|-- "UInt64" "ValueType" <|-- "UInt64" "IBinaryInteger" <|-- "UIntPtr" "IMinMaxValue" <|-- "UIntPtr" "ISerializable" <|-- "UIntPtr" -"IUnsignedNumber" <|-- "UIntPtr" +"IUnsignedNumberBase" <|-- "UIntPtr" "ValueType" <|-- "UIntPtr" "Object" <|-- "ValueType" @@ -451,7 +455,7 @@ class "Vector4" @enduml --> -![UML](http://www.plantuml.com/plantuml/svg/r9Z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aces build upon the base interfaces by defining the core abstr ```csharp namespace System { - public interface INumber + public interface INumberBase : IAdditionOperators, IAdditiveIdentity, - IComparisonOperators, // implies IEqualityOperators + IEqualityOperators, // implies IEquatable + IMultiplyOperators, + ISubtractionOperators, + IUnaryPlusOperators + where TSelf : INumberBase + { + // Alias for AdditiveIdentity + static abstract TSelf Zero { get; } + } + + public interface INumber + : IComparisonOperators, // implies IEqualityOperators IDecrementOperators, IDivisionOperators, IIncrementOperators, IModulusOperators, IMultiplicativeIdentity, - IMultiplyOperators, + INumberBase, ISpanFormattable, // implies IFormattable ISpanParseable, // implies IParseable - ISubtractionOperators, - IUnaryNegationOperators, - IUnaryPlusOperators + IUnaryNegationOperators where TSelf : INumber { // For the Create methods, there is some concern over users implementing them. It is not necessarily trivial to take an arbitrary TOther @@ -703,9 +716,6 @@ namespace System // Alias for MultiplicativeIdentity static abstract TSelf One { get; } - // Alias for AdditiveIdentity - static abstract TSelf Zero { get; } - // Abs mirrors Math.Abs and returns the same type. This can fail for MinValue of signed integer types // Swift has an associated type that can be used here, which would require an additional type parameter in .NET // However that would hinder the reusability of these interfaces in constraints @@ -737,20 +747,20 @@ namespace System static abstract bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out TSelf result); } - public interface ISignedNumber - : INumber - where TSelf : ISignedNumber + public interface ISignedNumberBase + : INumberBase + where TSelf : ISignedNumberBase { - // It's not possible to check for lack of an interface in a constraint, so ISignedNumber is likely required + // It's not possible to check for lack of an interface in a constraint, so ISignedNumberBase is likely required static abstract TSelf NegativeOne { get; } } - public interface IUnsignedNumber - : INumber - where TSelf : IUnsignedNumber + public interface IUnsignedNumberBase + : INumberBase + where TSelf : IUnsignedNumberBase { - // It's not possible to check for lack of an interface in a constraint, so IUnsignedNumber is likely required + // It's not possible to check for lack of an interface in a constraint, so IUnsignedNumberBase is likely required } public interface IBinaryNumber @@ -790,7 +800,7 @@ namespace System } public interface IFloatingPoint - : ISignedNumber + : ISignedNumberBase where TSelf : IFloatingPoint { // This currently implies IEEE floating-point types and so decimal does not implement it @@ -1219,7 +1229,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - IUnsignedNumber + IUnsignedNumberBase { } @@ -1227,7 +1237,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - IUnsignedNumber + IUnsignedNumberBase { } @@ -1273,7 +1283,7 @@ namespace System IDeserializationCallback, IMinMaxValue, ISerializable, - ISignedNumber + ISignedNumberBase { // Decimal defines a few additional operations like Ceiling, Floor, Round, and Truncate // The rest of the IEEE operations are missing. @@ -1313,7 +1323,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - ISignedNumber + ISignedNumberBase { } @@ -1321,7 +1331,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - ISignedNumber + ISignedNumberBase { } @@ -1329,7 +1339,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - ISignedNumber + ISignedNumberBase { } @@ -1337,7 +1347,7 @@ namespace System : IBinaryInteger, IMinMaxValue, ISerializable, - ISignedNumber + ISignedNumberBase { } @@ -1345,7 +1355,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - ISignedNumber + ISignedNumberBase { } @@ -1384,7 +1394,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - IUnsignedNumber + IUnsignedNumberBase { } @@ -1392,7 +1402,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - IUnsignedNumber + IUnsignedNumberBase { } @@ -1400,7 +1410,7 @@ namespace System : IBinaryInteger, IConvertible, IMinMaxValue, - IUnsignedNumber + IUnsignedNumberBase { } @@ -1408,7 +1418,7 @@ namespace System : IBinaryInteger, IMinMaxValue, ISerializable, - IUnsignedNumber + IUnsignedNumberBase { } } From 4bd41de25f741a0cb3f12706b5fe4359b5d6dae4 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 14 Jan 2022 14:43:15 -0800 Subject: [PATCH 02/16] Move DivRem down to IBinaryInteger --- accepted/2021/statics-in-interfaces/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 390a0fbd4..a08582d00 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -724,8 +724,6 @@ namespace System static abstract TSelf Clamp(TSelf value, TSelf min, TSelf max); - static abstract (TSelf Quotient, TSelf Remainder) DivRem(TSelf left, TSelf right); - static abstract TSelf Max(TSelf x, TSelf y); static abstract TSelf Min(TSelf x, TSelf y); @@ -788,6 +786,8 @@ namespace System // Returning int is currently what BitOperations does, however this can be cumbersome or prohibitive // in various algorithms where returning TSelf is better. + static abstract (TSelf Quotient, TSelf Remainder) DivRem(TSelf left, TSelf right); + static abstract TSelf LeadingZeroCount(TSelf value); static abstract TSelf PopCount(TSelf value); From caf5c28ba62dd3c619ac036601de956235d3c27a Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 14 Jan 2022 16:25:36 -0800 Subject: [PATCH 03/16] Splitting apart IFloatingPoint into IFloatingPoint and IFloatingPointIeee754 + a few I*Functions interfaces --- accepted/2021/statics-in-interfaces/README.md | 261 +++++++++++------- 1 file changed, 157 insertions(+), 104 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index a08582d00..b6f75c5b6 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -175,7 +175,7 @@ The overall design has been influenced by the existing .NET surface area, the Sw @startuml interface "IAdditionOperators" interface "IAdditiveIdentity" -interface "IBinaryFloatingPoint" +interface "IBinaryFloatingPointIeee754" interface "IBinaryInteger" interface "IBinaryNumber" interface "IBitwiseOperators" @@ -188,9 +188,13 @@ interface "IDeserializationCallback" interface "IDivisionOperators" interface "IEqualityOperators" interface "IEquatable" +interface "IExponentialFunctions" interface "IFloatingPoint" -interface "IIncrementOperators" +interface "IFloatingPointIeee754" interface "IFormattable" +interface "IHyperbolicFunctions" +interface "IIncrementOperators" +interface "ILogarithmicFunctions" interface "IMinMaxValue" interface "IModulusOperators" interface "IMultiplicativeIdentity" @@ -198,19 +202,22 @@ interface "IMultiplyOperators" interface "INumber" interface "INumberBase" interface "IParseable" +interface "IPowerFunctions" +interface "IRootFunctions" interface "ISerializable" interface "IShiftOperators" interface "ISignedNumberBase" interface "ISpanFormattable" interface "ISpanParseable" interface "ISubtractionOperators" +interface "ITrigonometricFunctions" interface "IUnsignedNumberBase" interface "IUnaryNegationOperators" interface "IUnaryPlusOperators" interface "IVector" -"IBinaryNumber" <|-- "IBinaryFloatingPoint" -"IFloatingPoint" <|-- "IBinaryFloatingPoint" +"IBinaryNumber" <|-- "IBinaryFloatingPointIeee754" +"IFloatingPointIeee754" <|-- "IBinaryFloatingPointIeee754" "IBinaryNumber" <|-- "IBinaryInteger" "IShiftOperators" <|-- "IBinaryInteger" @@ -226,6 +233,14 @@ interface "IVector" "ISignedNumberBase" <|-- "IFloatingPoint" +"IExponentialFunctions" <|-- "IFloatingPointIeee754" +"IHyperbolicFunctions" <|-- "IFloatingPointIeee754" +"ILogarithmicFunctions" <|-- "IFloatingPointIeee754" +"IFloatingPoint" <|-- "IFloatingPointIeee754" +"IPowerFunctions" <|-- "IFloatingPointIeee754" +"IRootFunctions" <|-- "IFloatingPointIeee754" +"ITrigonometricFunctions" <|-- "IFloatingPointIeee754" + "IComparisonOperators" <|-- "INumber" "IDecrementOperators" <|-- "INumber" "IDivisionOperators" <|-- "INumber" @@ -344,7 +359,7 @@ class "Vector4" "ISignedNumberBase" <|-- "Decimal" "ValueType" <|-- "Decimal" -"IBinaryFloatingPoint" <|-- "Double" +"IBinaryFloatingPointIeee754" <|-- "Double" "IConvertible" <|-- "Double" "IMinMaxValue" <|-- "Double" "ValueType" <|-- "Double" @@ -359,7 +374,7 @@ class "Vector4" "ISpanParseable" <|-- "Guid" "ValueType" <|-- "Guid" -"IBinaryFloatingPoint" <|-- "Half" +"IBinaryFloatingPointIeee754" <|-- "Half" "IMinMaxValue" <|-- "Half" "ValueType" <|-- "Half" @@ -393,7 +408,7 @@ class "Vector4" "ISignedNumberBase" <|-- "SByte" "ValueType" <|-- "SByte" -"IBinaryFloatingPoint" <|-- "Single" +"IBinaryFloatingPointIeee754" <|-- "Single" "IConvertible" <|-- "Single" "IMinMaxValue" <|-- "Single" "ValueType" <|-- "Single" @@ -455,7 +470,7 @@ class "Vector4" @enduml --> -![UML](http://www.plantuml.com/plantuml/svg/h9ZDSjCm4CVlVefCplJG3p8SEXteHy67a0nEUbyxcrGWoq5Q5ypmyBXbwZIoDf8ruSBiUlSdhRJTlzgFXa1JNSf4A4AzXW97u_JJQYL8L6gsHGrKQNEvo52ktuqMCtf4tVx_3KqjwMhiI7l2T8MA13LTbZFwMYZGpRsiW8JQp2kXw7-2CovjFHlK1oA-rcNE1j0lON1WEJTLkGKDkKJEVxbmfWZ37bqlNZsX9j5RunOBZIKgiZXNTfX1BK2AF_1yNpSWPGx53oj8F0ap_3RlVjOjc1ecpH5DpZFntt2gWegzhtG9HFqBcGerXTyF86jq9awhLIrhCx3-QUiIMoaAO7gQpsa6BiMrRlVf6eoxj3beWv1BzzVijJbwHvOzYZKDt6KcDWfNdWrbMr2kY-e-UdPSvwIXY1W-IsL2zhTy6HMu0VSIFNINCvUr2On_mA8DwcAo0YJeDYPnZweH--_oxyc9Pr8oFr_noEXjCeCwkDT2OCc0MMxJx7fQLcY18oyhsPCBZc310WN3LfnZelrJFXQTM9eGUY9-sKduKNIGp7PxG3bzMg-PUCdkKWCeuM9zY9Ag8-mbN3SFK89rrBENmBlsK6nruWayXP6nWPHW9Jf8IOQyrIsC9PBUvxjL8aEA7IeCAVn1vICDUbaS80Kz1uAgY-jgQ_XPGBwvUM3_pPOu7fQX83inlaxcHHVVzypBBBxvULpKAuN7HIaKZukIAXuNfLayBbL7tLsKYl6uA3dpufeZdLsKm36uYA79us8bZySbXG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jIfksAgSsROgjFkKISKfuMIHSFD6kCm1ml4N21yxmxIVVF4VVhXe43vQLXwDiwvvqO5bnq97Qh6mv5ZBUFCo1pjNBEnNYuK5nvgrvuKLh1aBBnrBrvPriGPV1iEIWs4N2nR1Wbsnsnqe5WoA1ODYmQHOi2lsS4-A1ODYmQ1OC2WMJ8hLn89LHyEoep6TH8DgqIZR4tQiWa7oO50y62GBnZEh3YX85WsQHSkwep6Tp5wlTw3YBU74Myg9j_jOFCWVxnsicktOEeWd0yJRq2tU31HlSx1u6tp5cu7ZpO3nDikADmF7ys7ppD4vMimJZMt_Q10kscNp_1nDiaMRR1wXerqs3z7H95kqoUOvEbfbuoGTxc4ud9NpC1q-rXHyXutleMDSVZhmTuK6tbwX0RcNQ9xkDHg_dnKvUuSRudqCyFZwyVBv_lO5) ### Base Interfaces @@ -799,90 +814,129 @@ namespace System static abstract TSelf TrailingZeroCount(TSelf value); } - public interface IFloatingPoint - : ISignedNumberBase - where TSelf : IFloatingPoint + public interface IExponentialFunctions + where TSelf : IExponentialFunctions { - // This currently implies IEEE floating-point types and so decimal does not implement it - // If we want decimal to implement it, we would need to move several methods down and define - // some IeeeFloatingPoint interface instead. This wasn't done for simplicity and because decimal - // is not an industry standard type. + static abstract TSelf Exp(TSelf x); - // TODO: The Exponent and Signifcand need to be exposed here - // They should return INumber here and IBinaryNumber on IBinaryFloatingPoint + // IEEE defines n to be an integral type, but not the size - // TODO: We may want to expose constants related to the subnormal and finite boundaries + static abstract TSelf ScaleB(TSelf x, TInteger n) + where TInteger : IBinaryInteger; - // The following constants are defined by System.Math and System.MathF today + // The following methods are approved but not yet implemented in the libraries - static abstract TSelf E { get; } + static abstract TSelf ExpM1(TSelf x); - static abstract TSelf PI { get; } + static abstract TSelf Exp2(TSelf x); - static abstract TSelf Tau { get; } + static abstract TSelf Exp2M1(TSelf x); - // The following methods are defined by System.Math and System.MathF today - // Exposing them on the interfaces means they will become available as statics on the primitive types - // This, in a way, obsoletes Math/MathF and brings float/double inline with how non-primitive types support similar functionality - // API review will need to determine if we'll want to continue adding APIs to Math/MathF in the future + static abstract TSelf Exp10(TSelf x); - static abstract TSelf Acos(TSelf x); + static abstract TSelf Exp10M1(TSelf x); + } + public interface IHyperbolicFunctions + where TSelf : IHyperbolicFunctions + { static abstract TSelf Acosh(TSelf x); - static abstract TSelf Asin(TSelf x); - static abstract TSelf Asinh(TSelf x); - static abstract TSelf Atan(TSelf x); + static abstract TSelf Atanh(TSelf x); - static abstract TSelf Atan2(TSelf y, TSelf x); + static abstract TSelf Cosh(TSelf x); - static abstract TSelf Atanh(TSelf x); + static abstract TSelf Sinh(TSelf x); - static abstract TSelf BitIncrement(TSelf x); + static abstract TSelf Tanh(TSelf x); + } - static abstract TSelf BitDecrement(TSelf x); + public interface ILogarithmicFunctions + where TSelf : ILogarithmicFunctions + { + // IEEE defines the result to be an integral type, but not the size + + static abstract TInteger ILogB(TSelf x) + where TInteger : IBinaryInteger; + + static abstract TSelf Log(TSelf x); + + static abstract TSelf Log(TSelf x, TSelf newBase); + + static abstract TSelf Log2(TSelf x); + + static abstract TSelf Log10(TSelf x); + + // The following methods are approved but not yet implemented in the libraries + + static abstract TSelf LogP1(TSelf x); + + static abstract TSelf Log2P1(TSelf x); + + static abstract TSelf Log10P1(TSelf x); + } + + public interface IPowerFunctions + where TSelf : IPowerFunctions + { + static abstract TSelf Pow(TSelf x, TSelf y); + } + public interface IRootFunctions + where TSelf : IRootFunctions + { static abstract TSelf Cbrt(TSelf x); - static abstract TSelf Ceiling(TSelf x); + static abstract TSelf Sqrt(TSelf x); - // CopySign is likely more general purpose and may apply to any signed number type - // It may even be applicable to unsigned numbers where it simply returns x, for convenience + // The following methods are approved but not yet implemented in the libraries - static abstract TSelf CopySign(TSelf x, TSelf y); + static abstract TSelf Root(TSelf x, TSelf n); + } - static abstract TSelf Cos(TSelf x); + public interface ITrigonometricFunctions + where TSelf : ITrigonometricFunctions + { + static abstract TSelf Acos(TSelf x); - static abstract TSelf Cosh(TSelf x); + static abstract TSelf Asin(TSelf x); - static abstract TSelf Exp(TSelf x); + static abstract TSelf Atan(TSelf x); - static abstract TSelf Floor(TSelf x); + static abstract TSelf Atan2(TSelf y, TSelf x); - static abstract TSelf FusedMultiplyAdd(TSelf x, TSelf y, TSelf z); + static abstract TSelf Cos(TSelf x); - static abstract TSelf IEEERemainder(TSelf x, TSelf y); + static abstract TSelf Sin(TSelf x); - // IEEE defines the result to be an integral type, but not the size + static abstract TSelf Tan(TSelf x); - static abstract TInteger ILogB(TSelf x) - where TInteger : IBinaryInteger; + // The following methods are approved but not yet implemented in the libraries - static abstract TSelf Log(TSelf x); + static abstract TSelf AcosPi(TSelf x); - static abstract TSelf Log(TSelf x, TSelf newBase); + static abstract TSelf AsinPi(TSelf x); - static abstract TSelf Log2(TSelf x); + static abstract TSelf AtanPi(TSelf x); - static abstract TSelf Log10(TSelf x); + static abstract TSelf Atan2Pi(TSelf y, TSelf x); - static abstract TSelf MaxMagnitude(TSelf x, TSelf y); + static abstract TSelf CosPi(TSelf x); - static abstract TSelf MinMagnitude(TSelf x, TSelf y); + static abstract TSelf SinPi(TSelf x); - static abstract TSelf Pow(TSelf x, TSelf y); + static abstract TSelf TanPi(TSelf x); + } + + public interface IFloatingPoint + : ISignedNumberBase + where TSelf : IFloatingPoint + { + static abstract TSelf Ceiling(TSelf x); + + static abstract TSelf Floor(TSelf x); static abstract TSelf Round(TSelf x); @@ -894,22 +948,53 @@ namespace System static abstract TSelf Round(TSelf x, TInteger digits, MidpointRounding mode) where TInteger : IBinaryInteger; - // IEEE defines n to be an integral type, but not the size + static abstract TSelf Truncate(TSelf x); + } - static abstract TSelf ScaleB(TSelf x, TInteger n) - where TInteger : IBinaryInteger; + public interface IFloatingPointIeee754 + : IExponentialFunctions, + IFloatingPoint, + IHyperbolicFunctions, + ILogarithmicFunctions, + IPowerFunctions, + IRootFunctions, + ITrigonometricFunctions + where TSelf : IFloatingPointIeee754 + { + // TODO: The Exponent and Signifcand need to be exposed here + // They should return INumber here and IBinaryNumber on IBinaryFloatingPointIeee754 - static abstract TSelf Sin(TSelf x); + // TODO: We may want to expose constants related to the subnormal and finite boundaries - static abstract TSelf Sinh(TSelf x); + // The following constants are defined by System.Math and System.MathF today - static abstract TSelf Sqrt(TSelf x); + static abstract TSelf E { get; } - static abstract TSelf Tan(TSelf x); + static abstract TSelf PI { get; } - static abstract TSelf Tanh(TSelf x); + static abstract TSelf Tau { get; } - static abstract TSelf Truncate(TSelf x); + // The following methods are defined by System.Math and System.MathF today + // Exposing them on the interfaces means they will become available as statics on the primitive types + // This, in a way, obsoletes Math/MathF and brings float/double inline with how non-primitive types support similar functionality + // API review will need to determine if we'll want to continue adding APIs to Math/MathF in the future + + static abstract TSelf BitIncrement(TSelf x); + + static abstract TSelf BitDecrement(TSelf x); + + // CopySign is likely more general purpose and may apply to any signed number type + // It may even be applicable to unsigned numbers where it simply returns x, for convenience + + static abstract TSelf CopySign(TSelf x, TSelf y); + + static abstract TSelf FusedMultiplyAdd(TSelf x, TSelf y, TSelf z); + + static abstract TSelf IEEERemainder(TSelf x, TSelf y); + + static abstract TSelf MaxMagnitude(TSelf x, TSelf y); + + static abstract TSelf MinMagnitude(TSelf x, TSelf y); // The following members are exposed on the floating-point types as constants today // This may be of concern when implementing the interface @@ -944,36 +1029,10 @@ namespace System // The following methods are approved but not yet implemented in the libraries - static abstract TSelf AcosPi(TSelf x); - - static abstract TSelf AsinPi(TSelf x); - - static abstract TSelf AtanPi(TSelf x); - - static abstract TSelf Atan2Pi(TSelf y, TSelf x); - static abstract TSelf Compound(TSelf x, TSelf n); - static abstract TSelf CosPi(TSelf x); - - static abstract TSelf ExpM1(TSelf x); - - static abstract TSelf Exp2(TSelf x); - - static abstract TSelf Exp2M1(TSelf x); - - static abstract TSelf Exp10(TSelf x); - - static abstract TSelf Exp10M1(TSelf x); - static abstract TSelf Hypot(TSelf x, TSelf y); - static abstract TSelf LogP1(TSelf x); - - static abstract TSelf Log2P1(TSelf x); - - static abstract TSelf Log10P1(TSelf x); - static abstract TSelf MaxMagnitudeNumber(TSelf x, TSelf y); static abstract TSelf MaxNumber(TSelf x, TSelf y); @@ -982,12 +1041,6 @@ namespace System static abstract TSelf MinNumber(TSelf x, TSelf y); - static abstract TSelf Root(TSelf x, TSelf n); - - static abstract TSelf SinPi(TSelf x); - - static abstract TSelf TanPi(TSelf x); - // The majority of the IEEE required operations are listed below // This doesn't include the recommended operations such as sin, cos, acos, etc @@ -1120,16 +1173,16 @@ namespace System // TSelf SetPayloadSignaling(TSelf x); } - public interface IBinaryFloatingPoint + public interface IBinaryFloatingPointIeee754 : IBinaryNumber, - IFloatingPoint - where TSelf : IBinaryFloatingPoint + IFloatingPointIeee754 + where TSelf : IBinaryFloatingPointIeee754 { } - public interface IDecimalFloatingPoint - : IFloatingPoint - where TSelf : IDecimalFloatingPoint + public interface IDecimalFloatingPointIeee754 + : IFloatingPointIeee754 + where TSelf : IDecimalFloatingPointIeee754 { // This interface is defined for convenience of viewing the IEEE requirements // it would not actually be defined until the .NET libraries requires it @@ -1292,7 +1345,7 @@ namespace System } public struct Double - : IBinaryFloatingPoint, + : IBinaryFloatingPointIeee754, IConvertible, IMinMaxValue { @@ -1314,7 +1367,7 @@ namespace System } public struct Half - : IBinaryFloatingPoint, + : IBinaryFloatingPointIeee754, IMinMaxValue { } @@ -1360,7 +1413,7 @@ namespace System } public struct Single - : IBinaryFloatingPoint, + : IBinaryFloatingPointIeee754, IConvertible, IMinMaxValue { From da4d53962a10aa77af089258bd5330d62f11fb0f Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 14 Jan 2022 16:29:38 -0800 Subject: [PATCH 04/16] Ensure decimal is properly updated to implement IFloatingPoint --- accepted/2021/statics-in-interfaces/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index b6f75c5b6..f0a19b0ae 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -354,9 +354,9 @@ class "Vector4" "IConvertible" <|-- "Decimal" "IDeserializationCallback" <|-- "Decimal" +"IFloatingPoint" <|-- "Decimal" "IMinMaxValue" <|-- "Decimal" "ISerializable" <|-- "Decimal" -"ISignedNumberBase" <|-- "Decimal" "ValueType" <|-- "Decimal" "IBinaryFloatingPointIeee754" <|-- "Double" @@ -470,7 +470,7 @@ class "Vector4" @enduml --> -![UML](http://www.plantuml.com/plantuml/svg/h9ZDKjim4CVlVefCpkN01saF3DFoGSbCQJ8uuRvsDebQMKhbDU1E7xw63WwHb8sib0kpwzLFkxAi_ogVIm93LI4JeGZD77BizOTVPZD1GglH2WsGDkNP94Kv_z2RZ6Y9flb_ZsKbwRpl6VQ8mnag4bItexpH5qA1gM-a1X9gCTP2qH0HFvwU_1ld3HysdWKQ9k9xLMHR0-X9bDYngajThC109d6R_spY7IBAhIlenAj7D2ISEQumDrYW8ejpReULQ0H8yHj8Q7K9KcQG_xI2nACekx_KwrzL0wQQgSIA9k-QN3-lj4950kHDfVANFFt5REm89Y9WpzneKm2H--vkwwQQJ4kHyxaCLT3wVzCBC8AMnIxUdL1tyFm0iaB_SpshP5LsV4LtZKkifCZ1y_NnO-gEKrbVb_le0af_QMCm9K8cjppLJsZujRlNclY8zEqZSDvtkXHpwbXgAXOAPpkgIbUWVBkiVSYNdLOP6SWZpjg94GkjT85aTcswgIf3Ifc-dfwu06ysRXRjcB6ioi3u1yoRe3OcpK62QM8I_-dTs_ftzkVW84n3-ECYdXoVj5_9WZTf22pf87OEpQgdOOKMsDl9IZRqbEUqi415jINvFw83P30MdLYY6RWY0RgSR3_3MB9VW1DUmbaQyt4oIjoBPN9o7CUq7ZkmEAPVzFPZkYgvVvwyriGmaw1lmuKw9vFJ83CrCvJWrfYZ3DN-kNHe0NbAM4ku8vVGWuEZk3qIns0fRZFLcHBOvB2KfCi5sS9O_LV0dRajYI75A1H32hyRyAIE_IrB2kWqWwgBsz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lstz7ejht-QDsrmjzvuCMciForjB3O4XORmc93M6pyddgRr4tpzJNDrnC8NyFZS_VbPLlRBRusH7ojUBuN0B_S3uH_lnGGNmk8huq1NmkG7nQWh_si3AqoBKQhNDwSddJhMNfXMgMNvxfABrAhz59TL-a5QvLfsLgbldtqfAbIy3e_nck5uQcqyFm_W1yxbschr_xdpmOTagFhpkbqr-MW4xRDXeaKcxRCjXxFOIwykTZmlcBRXjbKsWwieJJPyD1iFROuM8UwXEkMuNIR2PV0u9QOuKDC34w9mIKnk2G6jyGCQ69YS4eCBed19J4u9cQK57TDXstJhRsWMsfqZkqvJwpW53cS4eTJP73yPfc0fiZedXaTzat7xkHdrjidK7oVGF6ro-7hUOoFyVDzWcNONaS7V1qQyFNIZUy5nBTxCBvUVF6zWFbUW7ovo-9h0VFvO_CIMsUwzyvq6_lJCJYwnzRxPph6HlVOUWjDzzXw4qstsEWUM--ZwHvRxwJntWpZCJayHuSVRi6tCF_x0lku_Ed0pHMOnzaABiZx4kxJPskuVfyjCdk6Xypz6E3fxVFrw-Fz6m00) ### Base Interfaces @@ -1334,9 +1334,9 @@ namespace System public struct Decimal : IConvertible, IDeserializationCallback, + IFloatingPoint, IMinMaxValue, - ISerializable, - ISignedNumberBase + ISerializable { // Decimal defines a few additional operations like Ceiling, Floor, Round, and Truncate // The rest of the IEEE operations are missing. From b361044ad711b02db609af4b66bbe64eaa8f5416 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 27 Mar 2022 08:50:31 -0700 Subject: [PATCH 05/16] Adding System.Numerics.BigInteger --- accepted/2021/statics-in-interfaces/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index f0a19b0ae..79066cdf4 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -1478,6 +1478,15 @@ namespace System namespace System.Numerics { + public struct BigInteger + : IBinaryInteger, + IMinMaxValue, + ISignedNumberBase, + ISpanFormattable, + ISpanParseable + { + } + public struct Vector : IVector, T> { } @@ -1520,7 +1529,6 @@ There are several types which may benefit from some interface support. These inc * System.Range * System.Tuple * System.ValueTuple -* System.Numerics.BigInteger * System.Numerics.Complex * System.Numerics.Matrix3x2 * System.Numerics.Matrix4x4 From af34c4c2cb31db3eb36effd03c59cba5fac1899c Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 27 Mar 2022 08:53:00 -0700 Subject: [PATCH 06/16] Remove `checked operators` that aren't going to be supported by the language --- accepted/2021/statics-in-interfaces/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 79066cdf4..3fae382f8 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -624,8 +624,6 @@ namespace System // Likewise the name IModulusOperators doesn't fit with the other names, so a better one is needed static abstract TResult operator %(TSelf left, TOther right); - - static abstract TResult checked operator %(TSelf left, TOther right); } public interface IUnaryNegationOperators @@ -640,8 +638,6 @@ namespace System where TSelf : IUnaryPlusOperators { static abstract TResult operator +(TSelf value); - - static abstract TResult checked operator +(TSelf value); } public interface IBitwiseOperators From 0c65a0a4a6b6c45e5f5ef375a0528974bb020a20 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 27 Mar 2022 09:00:59 -0700 Subject: [PATCH 07/16] Moving IDecrementOperators, IIncrementOperators, IMultiplicativeIdentity, and IUnaryNegationOperators down to INumberBase --- accepted/2021/statics-in-interfaces/README.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 3fae382f8..4d70ecdc1 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -242,22 +242,22 @@ interface "IVector" "ITrigonometricFunctions" <|-- "IFloatingPointIeee754" "IComparisonOperators" <|-- "INumber" -"IDecrementOperators" <|-- "INumber" "IDivisionOperators" <|-- "INumber" -"IIncrementOperators" <|-- "INumber" "IModulusOperators" <|-- "INumber" -"IMultiplicativeIdentity" <|-- "INumber" "INumberBase" <|-- "INumber" "ISpanFormattable" <|-- "INumber" "ISpanParseable" <|-- "INumber" -"IUnaryNegationOperators" <|-- "INumber" "IAdditionOperators" <|-- "INumberBase" "IAdditiveIdentity" <|-- "INumberBase" +"IDecrementOperators" <|-- "INumberBase" "IEqualityOperators" <|-- "INumberBase" +"IIncrementOperators" <|-- "INumberBase" +"IMultiplicativeIdentity" <|-- "INumberBase" "IMultiplyOperators" <|-- "INumberBase" "ISubtractionOperators" <|-- "INumberBase" "IUnaryPlusOperators" <|-- "INumberBase" +"IUnaryNegationOperators" <|-- "INumberBase" "INumberBase" <|-- "ISignedNumberBase" @@ -685,27 +685,30 @@ namespace System public interface INumberBase : IAdditionOperators, IAdditiveIdentity, + IDecrementOperators, IEqualityOperators, // implies IEquatable + IIncrementOperators, + IMultiplicativeIdentity, IMultiplyOperators, ISubtractionOperators, - IUnaryPlusOperators + IUnaryPlusOperators, + IUnaryNegationOperators where TSelf : INumberBase { + // Alias for MultiplicativeIdentity + static abstract TSelf One { get; } + // Alias for AdditiveIdentity static abstract TSelf Zero { get; } } public interface INumber : IComparisonOperators, // implies IEqualityOperators - IDecrementOperators, IDivisionOperators, - IIncrementOperators, IModulusOperators, - IMultiplicativeIdentity, INumberBase, ISpanFormattable, // implies IFormattable ISpanParseable, // implies IParseable - IUnaryNegationOperators where TSelf : INumber { // For the Create methods, there is some concern over users implementing them. It is not necessarily trivial to take an arbitrary TOther @@ -724,9 +727,6 @@ namespace System // There is an open question on whether properties like IsSigned, IsBinary, IsFixedWidth, Base/Radix, and others are beneficial // We could expose them for trivial checks or users could be required to check for the corresponding correct interfaces - // Alias for MultiplicativeIdentity - static abstract TSelf One { get; } - // Abs mirrors Math.Abs and returns the same type. This can fail for MinValue of signed integer types // Swift has an associated type that can be used here, which would require an additional type parameter in .NET // However that would hinder the reusability of these interfaces in constraints From 6095e41873e84a2722f7f3b915eba0cffff0426f Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 27 Mar 2022 09:39:39 -0700 Subject: [PATCH 08/16] Explicitly show the new constants for the primitive types --- accepted/2021/statics-in-interfaces/README.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 4d70ecdc1..5aadb11f4 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -1280,6 +1280,10 @@ namespace System IMinMaxValue, IUnsignedNumberBase { + public const byte AdditiveIdentity = 0; + public const byte MultiplicativeIdentity = 1; + public const byte One = 1; + public const byte Zero = 0; } public struct Char @@ -1338,6 +1342,14 @@ namespace System // The rest of the IEEE operations are missing. // Decimal and some other types likewise define "friendly" names for operators, should we expose them? + + // Decimal exposes a member named MinusOne + + public const decimal AdditiveIdentity = 0; + public const decimal MultiplicativeIdentity = 1; + public const decimal NegativeOne = 1; + public const decimal One = 1; + public const decimal Zero = 0; } public struct Double @@ -1345,6 +1357,11 @@ namespace System IConvertible, IMinMaxValue { + public const double AdditiveIdentity = 0; + public const double MultiplicativeIdentity = 1; + public const double NegativeOne = 1; + public const double One = 1; + public const double Zero = 0; } public class Enum @@ -1374,6 +1391,11 @@ namespace System IMinMaxValue, ISignedNumberBase { + public const short AdditiveIdentity = 0; + public const short MultiplicativeIdentity = 1; + public const short NegativeOne = 1; + public const short One = 1; + public const short Zero = 0; } public struct Int32 @@ -1382,6 +1404,11 @@ namespace System IMinMaxValue, ISignedNumberBase { + public const int AdditiveIdentity = 0; + public const int MultiplicativeIdentity = 1; + public const int NegativeOne = 1; + public const int One = 1; + public const int Zero = 0; } public struct Int64 @@ -1390,6 +1417,11 @@ namespace System IMinMaxValue, ISignedNumberBase { + public const long AdditiveIdentity = 0; + public const long MultiplicativeIdentity = 1; + public const long NegativeOne = 1; + public const long One = 1; + public const long Zero = 0; } public struct IntPtr @@ -1406,6 +1438,11 @@ namespace System IMinMaxValue, ISignedNumberBase { + public const sbyte AdditiveIdentity = 0; + public const sbyte MultiplicativeIdentity = 1; + public const sbyte NegativeOne = 1; + public const sbyte One = 1; + public const sbyte Zero = 0; } public struct Single @@ -1413,6 +1450,11 @@ namespace System IConvertible, IMinMaxValue { + public const float AdditiveIdentity = 0; + public const float MultiplicativeIdentity = 1; + public const float NegativeOne = 1; + public const float One = 1; + public const float Zero = 0; } public struct TimeOnly @@ -1445,6 +1487,10 @@ namespace System IMinMaxValue, IUnsignedNumberBase { + public const ushort AdditiveIdentity = 0; + public const ushort MultiplicativeIdentity = 1; + public const ushort One = 1; + public const ushort Zero = 0; } public struct UInt32 @@ -1453,6 +1499,10 @@ namespace System IMinMaxValue, IUnsignedNumberBase { + public const uint AdditiveIdentity = 0; + public const uint MultiplicativeIdentity = 1; + public const uint One = 1; + public const uint Zero = 0; } public struct UInt64 @@ -1461,6 +1511,10 @@ namespace System IMinMaxValue, IUnsignedNumberBase { + public const ulong AdditiveIdentity = 0; + public const ulong MultiplicativeIdentity = 1; + public const ulong One = 1; + public const ulong Zero = 0; } public struct UIntPtr From f9847c90a2f51d55c6b7f8caed37fcadd4766290 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 27 Mar 2022 09:45:51 -0700 Subject: [PATCH 09/16] Adding System.Numerics.Complex --- accepted/2021/statics-in-interfaces/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 5aadb11f4..7bf1421c1 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -1537,6 +1537,17 @@ namespace System.Numerics { } + public struct Complex + : IAdditionOperators, + IDivisionOperators, + IDivisionOperators, + IFormattable, + IMultiplyOperators, + INumberBase, + ISubtractionOperators + { + } + public struct Vector : IVector, T> { } @@ -1579,7 +1590,6 @@ There are several types which may benefit from some interface support. These inc * System.Range * System.Tuple * System.ValueTuple -* System.Numerics.Complex * System.Numerics.Matrix3x2 * System.Numerics.Matrix4x4 * System.Numerics.Plane From 4878eb4dc029ecab7992e9ba3062ea2e32a38175 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 28 Mar 2022 08:34:39 -0700 Subject: [PATCH 10/16] Adding BigInteger and Complex to the UML metadata --- accepted/2021/statics-in-interfaces/README.md | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 7bf1421c1..0256ed559 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -281,8 +281,10 @@ interface "IVector" "ISubtractionOperators" <|-- "IVector" "IUnaryNegationOperators" <|-- "IVector" +class "BigInteger" class "Byte" class "Char" +class "Complex" class "DateOnly" class "DateTime" class "DateTimeOffset" @@ -312,6 +314,10 @@ class "Vector2" class "Vector3" class "Vector4" +"IBinaryInteger" <|-- "BigInteger" +"ISignedNumberBase" <|-- "BigInteger" +"ValueType" <|-- "BigInteger" + "IBinaryInteger" <|-- "Byte" "IConvertible" <|-- "Byte" "IMinMaxValue" <|-- "Byte" @@ -324,6 +330,21 @@ class "Vector4" "IUnsignedNumberBase" <|-- "Char" "ValueType" <|-- "Char" +"IAdditionOperators" <|-- "Complex" +"IDivisionOperators" <|-- "Complex" +"IDivisionOperators" <|-- "Complex" +"IFormattable" <|-- "Complex" +"IExponentialFunctions" <|-- "Complex" +"IHyperbolicFunctions" <|-- "Complex" +"ILogarithmicFunctions" <|-- "Complex" +"IMultiplyOperators" <|-- "Complex" +"INumberBase" <|-- "Complex" +"IPowerFunctions" <|-- "Complex" +"IRootFunctions" <|-- "Complex" +"ITrigonometricFunctions" <|-- "Complex" +"ISubtractionOperators" <|-- "Complex" +"ValueType" <|-- "Complex" + "IComparisonOperators" <|-- "DateOnly" "IMinMaxValue" <|-- "DateOnly" "ISpanFormattable" <|-- "DateOnly" @@ -1530,7 +1551,6 @@ namespace System.Numerics { public struct BigInteger : IBinaryInteger, - IMinMaxValue, ISignedNumberBase, ISpanFormattable, ISpanParseable @@ -1542,8 +1562,14 @@ namespace System.Numerics IDivisionOperators, IDivisionOperators, IFormattable, + // IExponentialFunctions, + // IHyperbolicFunctions, + // ILogarithmicFunctions, IMultiplyOperators, INumberBase, + // IPowerFunctions + // IRootFunctions, + // ITrigonometricFunctions, ISubtractionOperators { } From 7dfb4a127ea959b5cb5d0dc544adf65dbbfa4506 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 29 Mar 2022 08:11:28 -0700 Subject: [PATCH 11/16] Moving a IsNegative, CopySign, and Max/MinMagnitude down to INumber --- accepted/2021/statics-in-interfaces/README.md | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 0256ed559..f18770d32 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -756,10 +756,18 @@ namespace System static abstract TSelf Clamp(TSelf value, TSelf min, TSelf max); + static abstract TSelf CopySign(TSelf x, TSelf y); + + static abstract bool IsNegative(TSelf value); + static abstract TSelf Max(TSelf x, TSelf y); + static abstract TSelf MaxMagnitude(TSelf x, TSelf y); + static abstract TSelf Min(TSelf x, TSelf y); + static abstract TSelf MinMagnitude(TSelf x, TSelf y); + static abstract TSelf Parse(string s, NumberStyles style, IFormatProvider? provider); static abstract TSelf Parse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider); @@ -906,6 +914,8 @@ namespace System { static abstract TSelf Cbrt(TSelf x); + static abstract TSelf Hypot(TSelf x, TSelf y); + static abstract TSelf Sqrt(TSelf x); // The following methods are approved but not yet implemented in the libraries @@ -1000,19 +1010,10 @@ namespace System static abstract TSelf BitDecrement(TSelf x); - // CopySign is likely more general purpose and may apply to any signed number type - // It may even be applicable to unsigned numbers where it simply returns x, for convenience - - static abstract TSelf CopySign(TSelf x, TSelf y); - static abstract TSelf FusedMultiplyAdd(TSelf x, TSelf y, TSelf z); static abstract TSelf IEEERemainder(TSelf x, TSelf y); - static abstract TSelf MaxMagnitude(TSelf x, TSelf y); - - static abstract TSelf MinMagnitude(TSelf x, TSelf y); - // The following members are exposed on the floating-point types as constants today // This may be of concern when implementing the interface @@ -1034,8 +1035,6 @@ namespace System static abstract bool IsNaN(TSelf value); - static abstract bool IsNegative(TSelf value); - static abstract bool IsNegativeInfinity(TSelf value); static abstract bool IsNormal(TSelf value); @@ -1048,8 +1047,6 @@ namespace System static abstract TSelf Compound(TSelf x, TSelf n); - static abstract TSelf Hypot(TSelf x, TSelf y); - static abstract TSelf MaxMagnitudeNumber(TSelf x, TSelf y); static abstract TSelf MaxNumber(TSelf x, TSelf y); From 5b97f5c9c014df62c160622a0a3d913c15caa719 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 29 Mar 2022 08:24:31 -0700 Subject: [PATCH 12/16] Expose methods allowing getting the underlying bytes/parts of a binary integer or IEEE 754 floating-point number --- accepted/2021/statics-in-interfaces/README.md | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index f18770d32..42dbea3e1 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -758,6 +758,8 @@ namespace System static abstract TSelf CopySign(TSelf x, TSelf y); + // IsEven, IsOdd, IsZero + static abstract bool IsNegative(TSelf value); static abstract TSelf Max(TSelf x, TSelf y); @@ -837,6 +839,20 @@ namespace System static abstract TSelf RotateRight(TSelf value, TSelf rotateAmount); static abstract TSelf TrailingZeroCount(TSelf value); + + // These methods allow getting the underlying bytes that represent the binary integer + + void CopyTo(Span destination); + + void CopyTo(byte[] destination); + + void CopyTo(byte[] destination, int startIndex); + + nuint GetByteCount(); + + nuint GetBitLength(); + + bool TryCopyTo(Span destination); } public interface IExponentialFunctions @@ -988,11 +1004,6 @@ namespace System ITrigonometricFunctions where TSelf : IFloatingPointIeee754 { - // TODO: The Exponent and Signifcand need to be exposed here - // They should return INumber here and IBinaryNumber on IBinaryFloatingPointIeee754 - - // TODO: We may want to expose constants related to the subnormal and finite boundaries - // The following constants are defined by System.Math and System.MathF today static abstract TSelf E { get; } @@ -1017,6 +1028,8 @@ namespace System // The following members are exposed on the floating-point types as constants today // This may be of concern when implementing the interface + // TODO: We may want to expose constants related to the subnormal and finite boundaries + static abstract TSelf Epsilon { get; } static abstract TSelf NaN { get; } @@ -1055,6 +1068,32 @@ namespace System static abstract TSelf MinNumber(TSelf x, TSelf y); + // These methods allow getting the underlying bytes that represent the IEEE 754 floating-point + + void CopyExponentTo(Span destination); + + void CopyExponentTo(byte[] destination); + + void CopyExponentTo(byte[] destination, int startIndex); + + nuint GetExponentByteCount(); + + nuint GetExponentBitLength(); + + bool TryCopyExponentTo(Span destination); + + void CopySignificandTo(Span destination); + + void CopySignificandTo(byte[] destination); + + void CopySignificandTo(byte[] destination, int startIndex); + + nuint GetSignificandByteCount(); + + nuint GetSignificandBitLength(); + + bool TryCopySignificandTo(Span destination); + // The majority of the IEEE required operations are listed below // This doesn't include the recommended operations such as sin, cos, acos, etc From fc962deb0c3578040d3f456d1f2099819388f4ff Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 31 Mar 2022 18:14:35 -0700 Subject: [PATCH 13/16] Updating the majority of the design doc to match the API review feedback --- accepted/2021/statics-in-interfaces/README.md | 2879 ++++++++++++++--- 1 file changed, 2475 insertions(+), 404 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 42dbea3e1..7848777ab 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -111,7 +111,7 @@ After thinking over the possible implementations, Jeff realizes that the only re Jeff learns that a future version of .NET will offer a new feature called static abstracts in interfaces. Such a feature will have the .NET Libraries expose a set of interfaces that allow Jeff to implement the desired method without requiring users types to take a dependency on types they declared. -The .NET Libraries are exposing interfaces such as: +The .NET Libraries are exposing interfaces such as (NOTE: simplified names/examples are given below): ```csharp public interface IAdditionOperators where TSelf : IAdditionOperators @@ -173,25 +173,30 @@ The overall design has been influenced by the existing .NET surface area, the Sw -![UML](http://www.plantuml.com/plantuml/svg/h9ZFKziw4CVl_YioEJyEGCXx1uPvvGSbCwN9u8JxsjaaQcKfbTQ0E_tZ6-ZWO5dPo4gvCBjUVQJL3trN-TyI62eBcGX5Q1QGOwy_-ZIV2n9QZTTeWBInvzCKvUAVtdHCApIR_mzeIqaNVK-p9npDKP6WgcxbZRuK2anrApMGKCk95ef6YFZlsU1FEs_uI14kqJ0HNyiYsnb0py9YnwokTB460vd4NVxpgRU9i3jdi1Mldj2GQFLnZRd10XKvd0itpA8H8CLF8A7L5KYPGVxT2H9FmdPVr9iV9KX15PE94qtUERbvMMk5YWJ8srBbh-Fq9zFO4Kn4m9wvrQO0elRQtLLhD9cM8kV7Cb91y_z5By48MXNxUFT2tSFB8yWI_T_rl9IbxRX4znkNM4kH0t_wF6sgZbsrJvVpwHAiFxK968kGoHrVzJCQVkuUj2O-8dq_1AtrJbTYGHrJJSLIuNnFLkaQb6-NrH_vjDCo8mDvn5qxDMAfbIwGpBvDDrCs99NPs-s9I_2EfXv5kyr4bZOm_X5pqgQEINEGO3OnYV_sxktyE_zrT1Ic8Vnr4K-E7xHVoO8tQGWiwI1sBitDPyCAJR2tbvKqz9JdrB10HNKb-I-Y0sGm5fqueXau8m6wdEo-mrYoNu0JNi8P6dE4M2NknJ5vEOvZEfzTM2JJBtg7CTigUVWuUQs9OIP1PwCDTMuJha1kvSfHWaj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ykXqqA5qv6D7_bki7Tmq40DX6BrlEIJYJ0-83k06tEWV2Mdq4SGYw_b00S-mVoRExDZNfXND2fRQ-Gf6Nm6_hr0Wjsnz1NgCAVARqud8elrbUhfepsPZ2nOYor9Oimb0M5a8AmjXZOMmnbgRr2RPJ_i_SEeyupAFYTEO94uJaJWs1d5usOxJw2LEKvOu3LJYrBN4yViMfsQzFiJscRprW7cRZUGjlpplMVLjz2wNzmym3pyoUIo0_EqD0VZxMa1vAg0yV7_pKe3vhGBiFM6t35l5Yx5LJc-gH9V-5o_CLl7oR9NT8cqLBzLMyO9jbRsoRHNRVNgRnKg9otbLt2eiBgKLbqyWVgoSiF_q3GxiWqj3ScbuyZGTWC-8H1uxEni0M7ZaiRGhpnX8Tgwni5-DXGVEKcdFg0jACml_z5YQ5Cn83keo38ySXf5KM08BUsANEqWi38c58R4m9HRsnEwla5WO4Wj3Oc58B8o9DVwMfqx3OwUXlKXBQccExH67n668F0o9XocoCFrcTNO2aQKjipGyTngxaw-t29z0vR73oLkNavVtiRp6dyS1GiTqDZh8Qm7aPMwVvmBAmo5xteRdUI_WF1LmNWeu3mVjURs7bBSlK1v_x9wyTKzByQRXf2zjmQKzDkpVqnPRscFJ5ZxjiM4JdxROqXwRzl5fZyqx-RWrut5Fpflv-37tTrPilZzw7AVtelvUeQiwla9NUto9RWBv6bqSsbjaxt-u8EyQqyFB-_F7s-id) ### Base Interfaces From bd3bce83bc2c7591283abf6085f9315946f93a7f Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 1 Apr 2022 13:11:17 -0700 Subject: [PATCH 15/16] Ensure ReciprocalEstimate, ReciprocalSqrtEstimate, and SinCos are covered --- accepted/2021/statics-in-interfaces/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index 5df32a258..fd7b09d2a 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -798,6 +798,8 @@ namespace System.Numerics static abstract TSelf Sin(TSelf x); + static abstract (TSelf Sin, TSelf Cos) SinCos(TSelf x); + static abstract TSelf Tan(TSelf x); // The following methods are approved but not yet implemented in the libraries @@ -958,6 +960,10 @@ namespace System.Numerics static abstract int ILogB(TSelf x); + static abstract TSelf ReciprocalEstimate(TSelf x); + + static abstract TSelf ReciprocalSqrtEstimate(TSelf x); + // IEEE defines n to be an integral type, but not the size static abstract TSelf ScaleB(TSelf x, int n); @@ -1959,6 +1965,8 @@ namespace System // * TSelf MaxNumber(TSelf, TSelf) // Approved - NYI // * TSelf MinMagnitudeNumber(TSelf, TSelf) // Approved - NYI // * TSelf MinNumber(TSelf, TSelf) // Approved - NYI + // * TSelf ReciprocalEstimate(TSelf) + // * TSelf ReciprocalSqrtEstimate(TSelf) // * TSelf ScaleB(TSelf, int) // * bool TryWriteExponentLittleEndian(byte[], out int) // Approved - NYI // * bool TryWriteSignificandLittleEndian(byte[], out int) // Approved - NYI @@ -2030,6 +2038,7 @@ namespace System // * TSelf Cos(TSelf) // * TSelf CosPi(TSelf) // Approved - NYI // * TSelf Sin(TSelf) + // * (TSelf, TSelf) SinCos(TSelf) // * TSelf SinPi(TSelf) // Approved - NYI // * TSelf Tan(TSelf) // * TSelf TanPi(TSelf) // Approved - NYI @@ -2170,6 +2179,8 @@ namespace System // * TSelf MaxNumber(TSelf, TSelf) // Approved - NYI // * TSelf MinMagnitudeNumber(TSelf, TSelf) // Approved - NYI // * TSelf MinNumber(TSelf, TSelf) // Approved - NYI + // * TSelf ReciprocalEstimate(TSelf) + // * TSelf ReciprocalSqrtEstimate(TSelf) // * TSelf ScaleB(TSelf, int) // * bool TryWriteExponentLittleEndian(byte[], out int) // Approved - NYI // * bool TryWriteSignificandLittleEndian(byte[], out int) // Approved - NYI @@ -2252,6 +2263,7 @@ namespace System // * TSelf Cos(TSelf) // * TSelf CosPi(TSelf) // Approved - NYI // * TSelf Sin(TSelf) + // * (TSelf, TSelf) SinCos(TSelf) // * TSelf SinPi(TSelf) // Approved - NYI // * TSelf Tan(TSelf) // * TSelf TanPi(TSelf) // Approved - NYI @@ -2996,6 +3008,8 @@ namespace System // * TSelf MaxNumber(TSelf, TSelf) // Approved - NYI // * TSelf MinMagnitudeNumber(TSelf, TSelf) // Approved - NYI // * TSelf MinNumber(TSelf, TSelf) // Approved - NYI + // * TSelf ReciprocalEstimate(TSelf) + // * TSelf ReciprocalSqrtEstimate(TSelf) // * TSelf ScaleB(TSelf, int) // * bool TryWriteExponentLittleEndian(byte[], out int) // Approved - NYI // * bool TryWriteSignificandLittleEndian(byte[], out int) // Approved - NYI @@ -3067,6 +3081,7 @@ namespace System // * TSelf Cos(TSelf) // * TSelf CosPi(TSelf) // Approved - NYI // * TSelf Sin(TSelf) + // * (TSelf, TSelf) SinCos(TSelf) // * TSelf SinPi(TSelf) // Approved - NYI // * TSelf Tan(TSelf) // * TSelf TanPi(TSelf) // Approved - NYI From 3c07dc6e79fe53a8f92cf18ed2d7781fb69db505 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 1 Apr 2022 13:58:23 -0700 Subject: [PATCH 16/16] Adding missing semicolons --- accepted/2021/statics-in-interfaces/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/accepted/2021/statics-in-interfaces/README.md b/accepted/2021/statics-in-interfaces/README.md index fd7b09d2a..e386ea495 100644 --- a/accepted/2021/statics-in-interfaces/README.md +++ b/accepted/2021/statics-in-interfaces/README.md @@ -1746,7 +1746,7 @@ namespace System public const decimal MinusOne = -1; // Existing - "Conflicts" with NegativeOne public const decimal MinValue = -79228162514264337593543950335m; // Existing public const decimal MultiplicativeIdentity = 1; // ? Expose - public const decimal NegativeOne = -1 // ? Expose + public const decimal NegativeOne = -1; // ? Expose public const decimal One = 1; // Existing public const decimal Zero = 0; // Existing @@ -1851,7 +1851,7 @@ namespace System public const double MaxValue = 1.7976931348623157E+308; // Existing public const double MinValue = -1.7976931348623157E+308; // Existing public const double MultiplicativeIdentity = 1; // ? Expose - public const double NegativeOne = -1 // ? Expose + public const double NegativeOne = -1; // ? Expose public const double NegativeZero = -0.0; public const double One = 1; // ? Expose public const double Pi = Math.PI; @@ -2894,7 +2894,7 @@ namespace System public const float MaxValue = 3.40282346638528859e+38f; // Existing public const float MinValue = -3.40282346638528859e+38f; // Existing public const float MultiplicativeIdentity = 1; // ? Expose - public const float NegativeOne = -1 // ? Expose + public const float NegativeOne = -1; // ? Expose public const float NegativeZero = -0.0f; public const float One = 1; // ? Expose public const float Pi = Math.PI;