diff --git a/src/libraries/Common/tests/System/GenericMathHelpers.cs b/src/libraries/Common/tests/System/GenericMathHelpers.cs index e469afb40aa194..b2ce6e4896fe18 100644 --- a/src/libraries/Common/tests/System/GenericMathHelpers.cs +++ b/src/libraries/Common/tests/System/GenericMathHelpers.cs @@ -297,6 +297,8 @@ public static class NumberBaseHelper { public static TSelf One => TSelf.One; + public static int Radix => TSelf.Radix; + public static TSelf Zero => TSelf.Zero; public static TSelf Abs(TSelf value) => TSelf.Abs(value); @@ -310,10 +312,20 @@ public static TSelf CreateSaturating(TOther value) public static TSelf CreateTruncating(TOther value) where TOther : INumberBase => TSelf.CreateTruncating(value); + public static bool IsCanonical(TSelf value) => TSelf.IsCanonical(value); + + public static bool IsComplexNumber(TSelf value) => TSelf.IsComplexNumber(value); + + public static bool IsEvenInteger(TSelf value) => TSelf.IsEvenInteger(value); + public static bool IsFinite(TSelf value) => TSelf.IsFinite(value); + public static bool IsImaginaryNumber(TSelf value) => TSelf.IsImaginaryNumber(value); + public static bool IsInfinity(TSelf value) => TSelf.IsInfinity(value); + public static bool IsInteger(TSelf value) => TSelf.IsInteger(value); + public static bool IsNaN(TSelf value) => TSelf.IsNaN(value); public static bool IsNegative(TSelf value) => TSelf.IsNegative(value); @@ -322,10 +334,18 @@ public static TSelf CreateTruncating(TOther value) public static bool IsNormal(TSelf value) => TSelf.IsNormal(value); + public static bool IsOddInteger(TSelf value) => TSelf.IsOddInteger(value); + + public static bool IsPositive(TSelf value) => TSelf.IsPositive(value); + public static bool IsPositiveInfinity(TSelf value) => TSelf.IsPositiveInfinity(value); + public static bool IsRealNumber(TSelf value) => TSelf.IsRealNumber(value); + public static bool IsSubnormal(TSelf value) => TSelf.IsSubnormal(value); + public static bool IsZero(TSelf value) => TSelf.IsZero(value); + public static TSelf MaxMagnitude(TSelf x, TSelf y) => TSelf.MaxMagnitude(x, y); public static TSelf MaxMagnitudeNumber(TSelf x, TSelf y) => TSelf.MaxMagnitudeNumber(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/BitConverter.cs b/src/libraries/System.Private.CoreLib/src/System/BitConverter.cs index 836d3de69a1d07..b5aa38e497d2e7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/BitConverter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/BitConverter.cs @@ -840,10 +840,7 @@ public static unsafe float Int32BitsToSingle(int value) /// The number to convert. /// A 16-bit signed integer whose bits are identical to . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe short HalfToInt16Bits(Half value) - { - return *((short*)&value); - } + public static unsafe short HalfToInt16Bits(Half value) => (short)HalfToUInt16Bits(value); /// /// Converts the specified 16-bit signed integer to a half-precision floating point number. @@ -851,10 +848,7 @@ public static unsafe short HalfToInt16Bits(Half value) /// The number to convert. /// A half-precision floating point number whose bits are identical to . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe Half Int16BitsToHalf(short value) - { - return *(Half*)&value; - } + public static unsafe Half Int16BitsToHalf(short value) => UInt16BitsToHalf((ushort)(value)); /// /// Converts the specified double-precision floating point number to a 64-bit unsigned integer. @@ -899,7 +893,7 @@ public static unsafe Half Int16BitsToHalf(short value) /// A 16-bit unsigned integer whose bits are identical to . [CLSCompliant(false)] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ushort HalfToUInt16Bits(Half value) => (ushort)HalfToInt16Bits(value); + public static unsafe ushort HalfToUInt16Bits(Half value) => value._value; /// /// Converts the specified 16-bit unsigned integer to a half-precision floating point number. @@ -908,6 +902,6 @@ public static unsafe Half Int16BitsToHalf(short value) /// A half-precision floating point number whose bits are identical to . [CLSCompliant(false)] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe Half UInt16BitsToHalf(ushort value) => Int16BitsToHalf((short)value); + public static unsafe Half UInt16BitsToHalf(ushort value) => new Half(value); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Byte.cs b/src/libraries/System.Private.CoreLib/src/System/Byte.cs index 88bcafbc5b11b7..0104da49a46dac 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Byte.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Byte.cs @@ -522,6 +522,9 @@ bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int b /// static byte INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static byte INumberBase.Zero => Zero; @@ -752,12 +755,27 @@ public static byte CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(byte value) => true; + + /// + static bool INumberBase.IsComplexNumber(byte value) => false; + + /// + public static bool IsEvenInteger(byte value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(byte value) => true; + /// + static bool INumberBase.IsImaginaryNumber(byte value) => false; + /// static bool INumberBase.IsInfinity(byte value) => false; + /// + static bool INumberBase.IsInteger(byte value) => true; + /// static bool INumberBase.IsNaN(byte value) => false; @@ -770,12 +788,24 @@ public static byte CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(byte value) => value != 0; + /// + public static bool IsOddInteger(byte value) => (value & 1) != 0; + + /// + static bool INumberBase.IsPositive(byte value) => true; + /// static bool INumberBase.IsPositiveInfinity(byte value) => false; + /// + static bool INumberBase.IsRealNumber(byte value) => true; + /// static bool INumberBase.IsSubnormal(byte value) => false; + /// + static bool INumberBase.IsZero(byte value) => (value == 0); + /// static byte INumberBase.MaxMagnitude(byte x, byte y) => Max(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/Char.cs b/src/libraries/System.Private.CoreLib/src/System/Char.cs index 345139f5d32bcc..fd3b1280859e0f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Char.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Char.cs @@ -1373,6 +1373,9 @@ bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int b /// static char INumberBase.One => (char)1; + /// + static int INumberBase.Radix => 2; + /// static char INumberBase.Zero => (char)0; @@ -1597,12 +1600,27 @@ static char INumberBase.CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(char value) => true; + + /// + static bool INumberBase.IsComplexNumber(char value) => false; + + /// + static bool INumberBase.IsEvenInteger(char value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(char value) => true; + /// + static bool INumberBase.IsImaginaryNumber(char value) => false; + /// static bool INumberBase.IsInfinity(char value) => false; + /// + static bool INumberBase.IsInteger(char value) => true; + /// static bool INumberBase.IsNaN(char value) => false; @@ -1615,12 +1633,24 @@ static char INumberBase.CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(char value) => value != 0; + /// + static bool INumberBase.IsOddInteger(char value) => (value & 1) != 0; + + /// + static bool INumberBase.IsPositive(char value) => true; + /// static bool INumberBase.IsPositiveInfinity(char value) => false; + /// + static bool INumberBase.IsRealNumber(char value) => true; + /// static bool INumberBase.IsSubnormal(char value) => false; + /// + static bool INumberBase.IsZero(char value) => (value == 0); + /// static char INumberBase.MaxMagnitude(char x, char y) => (char)Math.Max(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs index 13abf7bb8f83c5..1fea9eba514a5c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.cs @@ -1332,6 +1332,9 @@ public static decimal Min(decimal x, decimal y) /// static decimal INumberBase.One => One; + /// + static int INumberBase.Radix => 10; + /// static decimal INumberBase.Zero => Zero; @@ -1585,12 +1588,51 @@ public static decimal CreateTruncating(TOther value) } } + /// + public static bool IsCanonical(decimal value) + { + uint scale = (byte)(value._flags >> ScaleShift); + + if (scale == 0) + { + // We have an exact integer represented with no trailing zero + return true; + } + + // We have some value where some fractional part is specified. So, + // if the least significant digit is 0, then we are not canonical + + if (value._hi32 == 0) + { + return (value._lo64 % 10) != 0; + } + + var significand = new UInt128(value._hi32, value._lo64); + return (significand % 10U) != 0U; + } + + /// + static bool INumberBase.IsComplexNumber(decimal value) => false; + + /// + public static bool IsEvenInteger(decimal value) + { + decimal truncatedValue = Truncate(value); + return (value == truncatedValue) && ((truncatedValue._lo64 & 1) == 0); + } + /// static bool INumberBase.IsFinite(decimal value) => true; + /// + static bool INumberBase.IsImaginaryNumber(decimal value) => false; + /// static bool INumberBase.IsInfinity(decimal value) => false; + /// + public static bool IsInteger(decimal value) => value == Truncate(value); + /// static bool INumberBase.IsNaN(decimal value) => false; @@ -1603,12 +1645,28 @@ public static decimal CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(decimal value) => value != 0; + /// + public static bool IsOddInteger(decimal value) + { + decimal truncatedValue = Truncate(value); + return (value == truncatedValue) && ((truncatedValue._lo64 & 1) != 0); + } + + /// + public static bool IsPositive(decimal value) => value._flags >= 0; + /// static bool INumberBase.IsPositiveInfinity(decimal value) => false; + /// + static bool INumberBase.IsRealNumber(decimal value) => true; + /// static bool INumberBase.IsSubnormal(decimal value) => false; + /// + static bool INumberBase.IsZero(decimal value) => (value == 0); + /// public static decimal MaxMagnitude(decimal x, decimal y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Double.cs b/src/libraries/System.Private.CoreLib/src/System/Double.cs index 85795e08a1ca02..a84a966f9c53f9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Double.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Double.cs @@ -994,6 +994,9 @@ public static double MinNumber(double x, double y) /// static double INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static double INumberBase.Zero => Zero; @@ -1092,6 +1095,41 @@ public static double CreateTruncating(TOther value) return CreateSaturating(value); } + /// + static bool INumberBase.IsCanonical(double value) => true; + + /// + static bool INumberBase.IsComplexNumber(double value) => false; + + /// + public static bool IsEvenInteger(double value) => IsInteger(value) && (Abs(value % 2) == 0); + + /// + static bool INumberBase.IsImaginaryNumber(double value) => false; + + /// + public static bool IsInteger(double value) => IsFinite(value) && (value == Truncate(value)); + + /// + public static bool IsOddInteger(double value) => IsInteger(value) && (Abs(value % 2) == 1); + + /// + public static bool IsPositive(double value) => BitConverter.DoubleToInt64Bits(value) >= 0; + + /// + public static bool IsRealNumber(double value) + { + // A NaN will never equal itself so this is an + // easy and efficient way to check for a real number. + +#pragma warning disable CS1718 + return value == value; +#pragma warning restore CS1718 + } + + /// + static bool INumberBase.IsZero(double value) => (value == 0); + /// public static double MaxMagnitude(double x, double y) => Math.MaxMagnitude(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/Half.cs b/src/libraries/System.Private.CoreLib/src/System/Half.cs index dd05cf4a056dfb..782abe963f7a37 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Half.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Half.cs @@ -92,7 +92,7 @@ public readonly struct Half /// public static Half MaxValue => new Half(MaxValueBits); // 65504 - private readonly ushort _value; + internal readonly ushort _value; internal Half(ushort value) { @@ -1186,6 +1186,9 @@ public static Half MinNumber(Half x, Half y) /// public static Half One => new Half(PositiveOneBits); + /// + static int INumberBase.Radix => 2; + /// public static Half Zero => new Half(PositiveZeroBits); @@ -1284,6 +1287,41 @@ public static Half CreateTruncating(TOther value) return CreateSaturating(value); } + /// + static bool INumberBase.IsCanonical(Half value) => true; + + /// + static bool INumberBase.IsComplexNumber(Half value) => false; + + /// + public static bool IsEvenInteger(Half value) => float.IsEvenInteger((float)value); + + /// + static bool INumberBase.IsImaginaryNumber(Half value) => false; + + /// + public static bool IsInteger(Half value) => float.IsInteger((float)value); + + /// + public static bool IsOddInteger(Half value) => float.IsOddInteger((float)value); + + /// + public static bool IsPositive(Half value) => (short)(value._value) >= 0; + + /// + public static bool IsRealNumber(Half value) + { + // A NaN will never equal itself so this is an + // easy and efficient way to check for a real number. + +#pragma warning disable CS1718 + return value == value; +#pragma warning restore CS1718 + } + + /// + static bool INumberBase.IsZero(Half value) => (value == Zero); + /// public static Half MaxMagnitude(Half x, Half y) => (Half)MathF.MaxMagnitude((float)x, (float)y); diff --git a/src/libraries/System.Private.CoreLib/src/System/Int128.cs b/src/libraries/System.Private.CoreLib/src/System/Int128.cs index 403e4e1e26683a..56919478ccca7d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int128.cs @@ -1265,6 +1265,9 @@ public static int Sign(Int128 value) /// public static Int128 One => new Int128(0, 1); + /// + static int INumberBase.Radix => 2; + /// public static Int128 Zero => default; @@ -1499,12 +1502,27 @@ public static Int128 CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(Int128 value) => true; + + /// + static bool INumberBase.IsComplexNumber(Int128 value) => false; + + /// + public static bool IsEvenInteger(Int128 value) => (value._lower & 1) == 0; + /// static bool INumberBase.IsFinite(Int128 value) => true; + /// + static bool INumberBase.IsImaginaryNumber(Int128 value) => false; + /// static bool INumberBase.IsInfinity(Int128 value) => false; + /// + static bool INumberBase.IsInteger(Int128 value) => true; + /// static bool INumberBase.IsNaN(Int128 value) => false; @@ -1517,14 +1535,24 @@ public static Int128 CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(Int128 value) => value != 0; - internal static bool IsPositive(Int128 value) => (long)value._upper >= 0; + /// + public static bool IsOddInteger(Int128 value) => (value._lower & 1) != 0; + + /// + public static bool IsPositive(Int128 value) => (long)value._upper >= 0; /// static bool INumberBase.IsPositiveInfinity(Int128 value) => false; + /// + static bool INumberBase.IsRealNumber(Int128 value) => true; + /// static bool INumberBase.IsSubnormal(Int128 value) => false; + /// + static bool INumberBase.IsZero(Int128 value) => (value == 0); + /// public static Int128 MaxMagnitude(Int128 x, Int128 y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Int16.cs b/src/libraries/System.Private.CoreLib/src/System/Int16.cs index e2708ba0815ea0..0456102d42d950 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int16.cs @@ -568,6 +568,9 @@ public static short CopySign(short value, short sign) /// static short INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static short INumberBase.Zero => Zero; @@ -795,12 +798,27 @@ public static short CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(short value) => true; + + /// + static bool INumberBase.IsComplexNumber(short value) => false; + + /// + public static bool IsEvenInteger(short value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(short value) => true; + /// + static bool INumberBase.IsImaginaryNumber(short value) => false; + /// static bool INumberBase.IsInfinity(short value) => false; + /// + static bool INumberBase.IsInteger(short value) => true; + /// static bool INumberBase.IsNaN(short value) => false; @@ -813,12 +831,24 @@ public static short CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(short value) => value != 0; + /// + public static bool IsOddInteger(short value) => (value & 1) != 0; + + /// + public static bool IsPositive(short value) => value >= 0; + /// static bool INumberBase.IsPositiveInfinity(short value) => false; + /// + static bool INumberBase.IsRealNumber(short value) => true; + /// static bool INumberBase.IsSubnormal(short value) => false; + /// + static bool INumberBase.IsZero(short value) => (value == 0); + /// public static short MaxMagnitude(short x, short y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Int32.cs b/src/libraries/System.Private.CoreLib/src/System/Int32.cs index 26870c2013651f..291030805a1897 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int32.cs @@ -560,6 +560,9 @@ public static int CopySign(int value, int sign) /// static int INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static int INumberBase.Zero => Zero; @@ -783,12 +786,27 @@ public static int CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(int value) => true; + + /// + static bool INumberBase.IsComplexNumber(int value) => false; + + /// + public static bool IsEvenInteger(int value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(int value) => true; + /// + static bool INumberBase.IsImaginaryNumber(int value) => false; + /// static bool INumberBase.IsInfinity(int value) => false; + /// + static bool INumberBase.IsInteger(int value) => true; + /// static bool INumberBase.IsNaN(int value) => false; @@ -801,12 +819,24 @@ public static int CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(int value) => value != 0; + /// + public static bool IsOddInteger(int value) => (value & 1) != 0; + + /// + public static bool IsPositive(int value) => value >= 0; + /// static bool INumberBase.IsPositiveInfinity(int value) => false; + /// + static bool INumberBase.IsRealNumber(int value) => true; + /// static bool INumberBase.IsSubnormal(int value) => false; + /// + static bool INumberBase.IsZero(int value) => (value == 0); + /// public static int MaxMagnitude(int x, int y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Int64.cs b/src/libraries/System.Private.CoreLib/src/System/Int64.cs index 879a1f09dbdb57..34b2add14624a5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int64.cs @@ -547,6 +547,9 @@ public static long CopySign(long value, long sign) /// static long INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static long INumberBase.Zero => Zero; @@ -765,12 +768,27 @@ public static long CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(long value) => true; + + /// + static bool INumberBase.IsComplexNumber(long value) => false; + + /// + public static bool IsEvenInteger(long value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(long value) => true; + /// + static bool INumberBase.IsImaginaryNumber(long value) => false; + /// static bool INumberBase.IsInfinity(long value) => false; + /// + static bool INumberBase.IsInteger(long value) => true; + /// static bool INumberBase.IsNaN(long value) => false; @@ -783,12 +801,24 @@ public static long CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(long value) => value != 0; + /// + public static bool IsOddInteger(long value) => (value & 1) != 0; + + /// + public static bool IsPositive(long value) => value >= 0; + /// static bool INumberBase.IsPositiveInfinity(long value) => false; + /// + static bool INumberBase.IsRealNumber(long value) => true; + /// static bool INumberBase.IsSubnormal(long value) => false; + /// + static bool INumberBase.IsZero(long value) => (value == 0); + /// public static long MaxMagnitude(long x, long y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs b/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs index d777a0565aef21..36de25a6061954 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs @@ -520,6 +520,9 @@ public static nint CopySign(nint value, nint sign) /// static nint INumberBase.One => 1; + /// + static int INumberBase.Radix => 2; + /// static nint INumberBase.Zero => 0; @@ -741,12 +744,27 @@ public static nint CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(nint value) => true; + + /// + static bool INumberBase.IsComplexNumber(nint value) => false; + + /// + public static bool IsEvenInteger(nint value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(nint value) => true; + /// + static bool INumberBase.IsImaginaryNumber(nint value) => false; + /// static bool INumberBase.IsInfinity(nint value) => false; + /// + static bool INumberBase.IsInteger(nint value) => true; + /// static bool INumberBase.IsNaN(nint value) => false; @@ -759,12 +777,24 @@ public static nint CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(nint value) => value != 0; + /// + public static bool IsOddInteger(nint value) => (value & 1) != 0; + + /// + public static bool IsPositive(nint value) => value >= 0; + /// static bool INumberBase.IsPositiveInfinity(nint value) => false; + /// + static bool INumberBase.IsRealNumber(nint value) => true; + /// static bool INumberBase.IsSubnormal(nint value) => false; + /// + static bool INumberBase.IsZero(nint value) => (value == 0); + /// public static nint MaxMagnitude(nint x, nint y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs index de2ca66735fc2b..c38edf1ca3b169 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/INumberBase.cs @@ -27,6 +27,9 @@ public interface INumberBase /// Gets the value 1 for the type. static abstract TSelf One { get; } + /// Gets the radix, or base, for the type. + static abstract int Radix { get; } + /// Gets the value 0 for the type. static abstract TSelf Zero { get; } @@ -61,16 +64,50 @@ static abstract TSelf CreateSaturating(TOther value) static abstract TSelf CreateTruncating(TOther value) where TOther : INumberBase; + /// Determines if a value is in its canonical representation. + /// The value to be checked. + /// true if is in its canonical representation; otherwise, false. + static abstract bool IsCanonical(TSelf value); + + /// Determines if a value represents a complex value. + /// The value to be checked. + /// true if is a complex number; otherwise, false. + /// This function returns false for a complex number a + bi where b is zero. + static abstract bool IsComplexNumber(TSelf value); + + /// Determines if a value represents an even integral value. + /// The value to be checked. + /// true if is an even integer; otherwise, false. + /// + /// This correctly handles floating-point values and so 2.0 will return true while 2.2 will return false. + /// This functioning returning false does not imply that will return true. A number with a fractional portion, 3.3, is not even nor odd. + /// + static abstract bool IsEvenInteger(TSelf value); + /// Determines if a value is finite. /// The value to be checked. /// true if is finite; otherwise, false. + /// This function returning false does not imply that will return true. NaN is not finite nor infinite. static abstract bool IsFinite(TSelf value); + /// Determines if a value represents an imaginary value. + /// The value to be checked. + /// true if is an imaginary number; otherwise, false. + /// This function returns false for a complex number a + bi where a is non-zero. + static abstract bool IsImaginaryNumber(TSelf value); + /// Determines if a value is infinite. /// The value to be checked. /// true if is infinite; otherwise, false. + /// This function returning false does not imply that will return true. NaN is not finite nor infinite. static abstract bool IsInfinity(TSelf value); + /// Determines if a value represents an integral value. + /// The value to be checked. + /// true if is an integer; otherwise, false. + /// This correctly handles floating-point values and so 2.0 and 3.0 will return true while 2.2 and 3.3 will return false. + static abstract bool IsInteger(TSelf value); + /// Determines if a value is NaN. /// The value to be checked. /// true if is NaN; otherwise, false. @@ -79,6 +116,7 @@ static abstract TSelf CreateTruncating(TOther value) /// Determines if a value is negative. /// The value to be checked. /// true if is negative; otherwise, false. + /// This function returning false does not imply that will return true. A complex number, a + bi for non-zero b, is not positive nor negative static abstract bool IsNegative(TSelf value); /// Determines if a value is negative infinity. @@ -91,16 +129,43 @@ static abstract TSelf CreateTruncating(TOther value) /// true if is normal; otherwise, false. static abstract bool IsNormal(TSelf value); + /// Determines if a value represents an odd integral value. + /// The value to be checked. + /// true if is an odd integer; otherwise, false. + /// + /// This correctly handles floating-point values and so 3.0 will return true while 3.3 will return false. + /// This functioning returning false does not imply that will return true. A number with a fractional portion, 3.3, is neither even nor odd. + /// + static abstract bool IsOddInteger(TSelf value); + + /// Determines if a value is positive. + /// The value to be checked. + /// true if is positive; otherwise, false. + /// This function returning false does not imply that will return true. A complex number, a + bi for non-zero b, is not positive nor negative + static abstract bool IsPositive(TSelf value); + /// Determines if a value is positive infinity. /// The value to be checked. /// true if is positive infinity; otherwise, false. static abstract bool IsPositiveInfinity(TSelf value); + /// Determines if a value represents a real value. + /// The value to be checked. + /// true if is a real number; otherwise, false. + /// This function returns true for a complex number a + bi where b is zero. + static abstract bool IsRealNumber(TSelf value); + /// Determines if a value is subnormal. /// The value to be checked. /// true if is subnormal; otherwise, false. static abstract bool IsSubnormal(TSelf value); + /// Determines if a value is zero. + /// The value to be checked. + /// true if is zero; otherwise, false. + /// This function treats both positive and negative zero as zero and so will return true for +0.0 and -0.0. + static abstract bool IsZero(TSelf value); + /// Compares two values to compute which is greater. /// The value to compare with . /// The value to compare with . diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs index cc02c76d4ad496..97f3a349c28683 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs @@ -1128,6 +1128,9 @@ bool IFloatingPoint.TryWriteSignificandLittleEndian(Span destinati /// static NFloat INumberBase.One => new NFloat(NativeType.One); + /// + static int INumberBase.Radix => 2; + /// static NFloat INumberBase.Zero => new NFloat(NativeType.Zero); @@ -1222,6 +1225,33 @@ public static NFloat CreateTruncating(TOther value) return CreateChecked(value); } + /// + static bool INumberBase.IsCanonical(NFloat value) => true; + + /// + static bool INumberBase.IsComplexNumber(NFloat value) => false; + + /// + public static bool IsEvenInteger(NFloat value) => NativeType.IsEvenInteger(value._value); + + /// + static bool INumberBase.IsImaginaryNumber(NFloat value) => false; + + /// + public static bool IsInteger(NFloat value) => NativeType.IsInteger(value._value); + + /// + public static bool IsOddInteger(NFloat value) => NativeType.IsOddInteger(value._value); + + /// + public static bool IsPositive(NFloat value) => NativeType.IsPositive(value._value); + + /// + public static bool IsRealNumber(NFloat value) => NativeType.IsRealNumber(value._value); + + /// + static bool INumberBase.IsZero(NFloat value) => (value == 0); + /// public static NFloat MaxMagnitude(NFloat x, NFloat y) => new NFloat(NativeType.MaxMagnitude(x._value, y._value)); diff --git a/src/libraries/System.Private.CoreLib/src/System/SByte.cs b/src/libraries/System.Private.CoreLib/src/System/SByte.cs index 291c018870cdb4..ff3edb4dd7ef8b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SByte.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SByte.cs @@ -575,6 +575,9 @@ public static sbyte CopySign(sbyte value, sbyte sign) /// static sbyte INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static sbyte INumberBase.Zero => Zero; @@ -805,15 +808,30 @@ public static sbyte CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(sbyte value) => true; + + /// + static bool INumberBase.IsComplexNumber(sbyte value) => false; + + /// + public static bool IsEvenInteger(sbyte value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(sbyte value) => true; + /// + static bool INumberBase.IsImaginaryNumber(sbyte value) => false; + /// static bool INumberBase.IsInfinity(sbyte value) => false; /// static bool INumberBase.IsNaN(sbyte value) => false; + /// + static bool INumberBase.IsInteger(sbyte value) => true; + /// public static bool IsNegative(sbyte value) => value < 0; @@ -823,12 +841,24 @@ public static sbyte CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(sbyte value) => value != 0; + /// + public static bool IsOddInteger(sbyte value) => (value & 1) != 0; + + /// + public static bool IsPositive(sbyte value) => value >= 0; + /// static bool INumberBase.IsPositiveInfinity(sbyte value) => false; + /// + static bool INumberBase.IsRealNumber(sbyte value) => true; + /// static bool INumberBase.IsSubnormal(sbyte value) => false; + /// + static bool INumberBase.IsZero(sbyte value) => (value == 0); + /// public static sbyte MaxMagnitude(sbyte x, sbyte y) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Single.cs b/src/libraries/System.Private.CoreLib/src/System/Single.cs index f4246c657a8bf2..2ff1aad7fcfd49 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Single.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Single.cs @@ -977,6 +977,9 @@ public static float MinNumber(float x, float y) /// static float INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static float INumberBase.Zero => Zero; @@ -1075,6 +1078,41 @@ public static float CreateTruncating(TOther value) return CreateSaturating(value); } + /// + static bool INumberBase.IsCanonical(float value) => true; + + /// + static bool INumberBase.IsComplexNumber(float value) => false; + + /// + public static bool IsEvenInteger(float value) => IsInteger(value) && (Abs(value % 2) == 0); + + /// + static bool INumberBase.IsImaginaryNumber(float value) => false; + + /// + public static bool IsInteger(float value) => IsFinite(value) && (value == Truncate(value)); + + /// + public static bool IsOddInteger(float value) => IsInteger(value) && (Abs((value) % 2) == 1); + + /// + public static bool IsPositive(float value) => BitConverter.SingleToInt32Bits(value) >= 0; + + /// + public static bool IsRealNumber(float value) + { + // A NaN will never equal itself so this is an + // easy and efficient way to check for a real number. + +#pragma warning disable CS1718 + return value == value; +#pragma warning restore CS1718 + } + + /// + static bool INumberBase.IsZero(float value) => (value == 0); + /// public static float MaxMagnitude(float x, float y) => MathF.MaxMagnitude(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt128.cs b/src/libraries/System.Private.CoreLib/src/System/UInt128.cs index a1bc8756d67d6f..90b370f61ea683 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt128.cs @@ -1335,6 +1335,9 @@ public static UInt128 Clamp(UInt128 value, UInt128 min, UInt128 max) /// public static UInt128 One => new UInt128(0, 1); + /// + static int INumberBase.Radix => 2; + /// public static UInt128 Zero => default; @@ -1564,12 +1567,27 @@ public static UInt128 CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(UInt128 value) => true; + + /// + static bool INumberBase.IsComplexNumber(UInt128 value) => false; + + /// + public static bool IsEvenInteger(UInt128 value) => (value._lower & 1) == 0; + /// static bool INumberBase.IsFinite(UInt128 value) => true; + /// + static bool INumberBase.IsImaginaryNumber(UInt128 value) => false; + /// static bool INumberBase.IsInfinity(UInt128 value) => false; + /// + static bool INumberBase.IsInteger(UInt128 value) => true; + /// static bool INumberBase.IsNaN(UInt128 value) => false; @@ -1582,12 +1600,24 @@ public static UInt128 CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(UInt128 value) => value != 0U; + /// + public static bool IsOddInteger(UInt128 value) => (value._lower & 1) != 0; + + /// + static bool INumberBase.IsPositive(UInt128 value) => true; + /// static bool INumberBase.IsPositiveInfinity(UInt128 value) => false; + /// + static bool INumberBase.IsRealNumber(UInt128 value) => true; + /// static bool INumberBase.IsSubnormal(UInt128 value) => false; + /// + static bool INumberBase.IsZero(UInt128 value) => (value == 0U); + /// static UInt128 INumberBase.MaxMagnitude(UInt128 x, UInt128 y) => Max(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt16.cs b/src/libraries/System.Private.CoreLib/src/System/UInt16.cs index c8715702c465ea..97b6e6b7a884aa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt16.cs @@ -517,6 +517,9 @@ bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int /// static ushort INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static ushort INumberBase.Zero => Zero; @@ -744,12 +747,27 @@ public static ushort CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(ushort value) => true; + + /// + static bool INumberBase.IsComplexNumber(ushort value) => false; + + /// + public static bool IsEvenInteger(ushort value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(ushort value) => true; + /// + static bool INumberBase.IsImaginaryNumber(ushort value) => false; + /// static bool INumberBase.IsInfinity(ushort value) => false; + /// + static bool INumberBase.IsInteger(ushort value) => true; + /// static bool INumberBase.IsNaN(ushort value) => false; @@ -762,12 +780,24 @@ public static ushort CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(ushort value) => value != 0; + /// + public static bool IsOddInteger(ushort value) => (value & 1) != 0; + + /// + static bool INumberBase.IsPositive(ushort value) => true; + /// static bool INumberBase.IsPositiveInfinity(ushort value) => false; + /// + static bool INumberBase.IsRealNumber(ushort value) => true; + /// static bool INumberBase.IsSubnormal(ushort value) => false; + /// + static bool INumberBase.IsZero(ushort value) => (value == 0); + /// static ushort INumberBase.MaxMagnitude(ushort x, ushort y) => Max(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt32.cs b/src/libraries/System.Private.CoreLib/src/System/UInt32.cs index be00a1d9f020c2..eddab867b0221c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt32.cs @@ -503,6 +503,9 @@ bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int b /// static uint INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static uint INumberBase.Zero => Zero; @@ -728,12 +731,27 @@ public static uint CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(uint value) => true; + + /// + static bool INumberBase.IsComplexNumber(uint value) => false; + + /// + public static bool IsEvenInteger(uint value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(uint value) => true; + /// + static bool INumberBase.IsImaginaryNumber(uint value) => false; + /// static bool INumberBase.IsInfinity(uint value) => false; + /// + static bool INumberBase.IsInteger(uint value) => true; + /// static bool INumberBase.IsNaN(uint value) => false; @@ -746,12 +764,24 @@ public static uint CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(uint value) => value != 0; + /// + public static bool IsOddInteger(uint value) => (value & 1) != 0; + + /// + static bool INumberBase.IsPositive(uint value) => true; + /// static bool INumberBase.IsPositiveInfinity(uint value) => false; + /// + static bool INumberBase.IsRealNumber(uint value) => true; + /// static bool INumberBase.IsSubnormal(uint value) => false; + /// + static bool INumberBase.IsZero(uint value) => (value == 0); + /// static uint INumberBase.MaxMagnitude(uint x, uint y) => Max(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt64.cs b/src/libraries/System.Private.CoreLib/src/System/UInt64.cs index 31c77db1a8ca4a..48607b8819fa9b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt64.cs @@ -502,6 +502,9 @@ bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int /// static ulong INumberBase.One => One; + /// + static int INumberBase.Radix => 2; + /// static ulong INumberBase.Zero => Zero; @@ -723,12 +726,27 @@ public static ulong CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(ulong value) => true; + + /// + static bool INumberBase.IsComplexNumber(ulong value) => false; + + /// + public static bool IsEvenInteger(ulong value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(ulong value) => true; + /// + static bool INumberBase.IsImaginaryNumber(ulong value) => false; + /// static bool INumberBase.IsInfinity(ulong value) => false; + /// + static bool INumberBase.IsInteger(ulong value) => true; + /// static bool INumberBase.IsNaN(ulong value) => false; @@ -741,12 +759,24 @@ public static ulong CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(ulong value) => value != 0; + /// + public static bool IsOddInteger(ulong value) => (value & 1) != 0; + + /// + static bool INumberBase.IsPositive(ulong value) => true; + /// static bool INumberBase.IsPositiveInfinity(ulong value) => false; + /// + static bool INumberBase.IsRealNumber(ulong value) => true; + /// static bool INumberBase.IsSubnormal(ulong value) => false; + /// + static bool INumberBase.IsZero(ulong value) => (value == 0); + /// static ulong INumberBase.MaxMagnitude(ulong x, ulong y) => Max(x, y); diff --git a/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs b/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs index a3e7404e73395f..4795ef4df67bfe 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs @@ -478,6 +478,9 @@ bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int /// static nuint INumberBase.One => 1; + /// + static int INumberBase.Radix => 2; + /// static nuint INumberBase.Zero => 0; @@ -702,12 +705,27 @@ public static nuint CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(nuint value) => true; + + /// + static bool INumberBase.IsComplexNumber(nuint value) => false; + + /// + public static bool IsEvenInteger(nuint value) => (value & 1) == 0; + /// static bool INumberBase.IsFinite(nuint value) => true; + /// + static bool INumberBase.IsImaginaryNumber(nuint value) => false; + /// static bool INumberBase.IsInfinity(nuint value) => false; + /// + static bool INumberBase.IsInteger(nuint value) => true; + /// static bool INumberBase.IsNaN(nuint value) => false; @@ -720,12 +738,24 @@ public static nuint CreateTruncating(TOther value) /// static bool INumberBase.IsNormal(nuint value) => value != 0; + /// + public static bool IsOddInteger(nuint value) => (value & 1) != 0; + + /// + static bool INumberBase.IsPositive(nuint value) => true; + /// static bool INumberBase.IsPositiveInfinity(nuint value) => false; + /// + static bool INumberBase.IsRealNumber(nuint value) => true; + /// static bool INumberBase.IsSubnormal(nuint value) => false; + /// + static bool INumberBase.IsZero(nuint value) => (value == 0); + /// static nuint INumberBase.MaxMagnitude(nuint x, nuint y) => Max(x, y); diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index 26d8e8535258d6..7d59b44cdad1ce 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -830,6 +830,7 @@ public static void Free(void* ptr) { } static System.Runtime.InteropServices.NFloat System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static System.Runtime.InteropServices.NFloat System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static System.Runtime.InteropServices.NFloat System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static System.Runtime.InteropServices.NFloat System.Numerics.INumberBase.Zero { get { throw null; } } static System.Runtime.InteropServices.NFloat System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static System.Runtime.InteropServices.NFloat Tau { get { throw null; } } @@ -868,14 +869,19 @@ public static void Free(void* ptr) { } public override int GetHashCode() { throw null; } public static System.Runtime.InteropServices.NFloat Ieee754Remainder(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } public static int ILogB(System.Runtime.InteropServices.NFloat x) { throw null; } + public static bool IsEvenInteger(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsFinite(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsInteger(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsNaN(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsNegative(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsNegativeInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsNormal(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsOddInteger(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsPositive(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsPositiveInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsPow2(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsRealNumber(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsSubnormal(System.Runtime.InteropServices.NFloat value) { throw null; } public static System.Runtime.InteropServices.NFloat Log(System.Runtime.InteropServices.NFloat x) { throw null; } public static System.Runtime.InteropServices.NFloat Log(System.Runtime.InteropServices.NFloat x, System.Runtime.InteropServices.NFloat newBase) { throw null; } @@ -981,6 +987,10 @@ public static void Free(void* ptr) { } bool System.Numerics.IFloatingPoint.TryWriteSignificandLittleEndian(System.Span destination, out int bytesWritten) { throw null; } static System.Runtime.InteropServices.NFloat System.Numerics.IIncrementOperators.operator checked ++(System.Runtime.InteropServices.NFloat value) { throw null; } static System.Runtime.InteropServices.NFloat System.Numerics.IMultiplyOperators.operator checked *(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(System.Runtime.InteropServices.NFloat value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(System.Runtime.InteropServices.NFloat value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(System.Runtime.InteropServices.NFloat value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(System.Runtime.InteropServices.NFloat value) { throw null; } static System.Runtime.InteropServices.NFloat System.Numerics.ISubtractionOperators.operator checked -(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } static System.Runtime.InteropServices.NFloat System.Numerics.IUnaryNegationOperators.operator checked -(System.Runtime.InteropServices.NFloat value) { throw null; } public static System.Runtime.InteropServices.NFloat Tan(System.Runtime.InteropServices.NFloat x) { throw null; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.GenericMath.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.GenericMath.cs index 4e7a33d08860b2..3e842bd7ab1fe9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.GenericMath.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.GenericMath.cs @@ -82,7 +82,7 @@ private static NFloat NegativeZero } } - private static NFloat PositiveOne + private static NFloat One { get { @@ -97,7 +97,7 @@ private static NFloat PositiveOne } } - private static NFloat PositiveTwo + private static NFloat Two { get { @@ -112,7 +112,7 @@ private static NFloat PositiveTwo } } - private static NFloat PositiveZero + private static NFloat Zero { get { @@ -165,41 +165,41 @@ private static void AssertBitwiseEqual(NFloat expected, NFloat actual) [Fact] public static void op_AdditionTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, AdditionOperatorsHelper.op_Addition(NFloat.NegativeInfinity, PositiveOne)); - AssertBitwiseEqual(NFloat.MinValue, AdditionOperatorsHelper.op_Addition(NFloat.MinValue, PositiveOne)); - AssertBitwiseEqual(PositiveZero, AdditionOperatorsHelper.op_Addition(NegativeOne, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(-MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(-MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(-NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(NegativeZero, PositiveOne)); - AssertBitwiseEqual(NFloat.NaN, AdditionOperatorsHelper.op_Addition(NFloat.NaN, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(PositiveZero, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_Addition(MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveTwo, AdditionOperatorsHelper.op_Addition(PositiveOne, PositiveOne)); - AssertBitwiseEqual(NFloat.MaxValue, AdditionOperatorsHelper.op_Addition(NFloat.MaxValue, PositiveOne)); - AssertBitwiseEqual(NFloat.PositiveInfinity, AdditionOperatorsHelper.op_Addition(NFloat.PositiveInfinity, PositiveOne)); + AssertBitwiseEqual(NFloat.NegativeInfinity, AdditionOperatorsHelper.op_Addition(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, AdditionOperatorsHelper.op_Addition(NFloat.MinValue, One)); + AssertBitwiseEqual(Zero, AdditionOperatorsHelper.op_Addition(NegativeOne, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(-MinNormal, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(-MaxSubnormal, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(-NFloat.Epsilon, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, AdditionOperatorsHelper.op_Addition(NFloat.NaN, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(Zero, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(NFloat.Epsilon, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(MaxSubnormal, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_Addition(MinNormal, One)); + AssertBitwiseEqual(Two, AdditionOperatorsHelper.op_Addition(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, AdditionOperatorsHelper.op_Addition(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, AdditionOperatorsHelper.op_Addition(NFloat.PositiveInfinity, One)); } [Fact] public static void op_CheckedAdditionTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, AdditionOperatorsHelper.op_CheckedAddition(NFloat.NegativeInfinity, PositiveOne)); - AssertBitwiseEqual(NFloat.MinValue, AdditionOperatorsHelper.op_CheckedAddition(NFloat.MinValue, PositiveOne)); - AssertBitwiseEqual(PositiveZero, AdditionOperatorsHelper.op_CheckedAddition(NegativeOne, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(-MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(-MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(-NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(NegativeZero, PositiveOne)); - AssertBitwiseEqual(NFloat.NaN, AdditionOperatorsHelper.op_CheckedAddition(NFloat.NaN, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(PositiveZero, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, AdditionOperatorsHelper.op_CheckedAddition(MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveTwo, AdditionOperatorsHelper.op_CheckedAddition(PositiveOne, PositiveOne)); - AssertBitwiseEqual(NFloat.MaxValue, AdditionOperatorsHelper.op_CheckedAddition(NFloat.MaxValue, PositiveOne)); - AssertBitwiseEqual(NFloat.PositiveInfinity, AdditionOperatorsHelper.op_CheckedAddition(NFloat.PositiveInfinity, PositiveOne)); + AssertBitwiseEqual(NFloat.NegativeInfinity, AdditionOperatorsHelper.op_CheckedAddition(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, AdditionOperatorsHelper.op_CheckedAddition(NFloat.MinValue, One)); + AssertBitwiseEqual(Zero, AdditionOperatorsHelper.op_CheckedAddition(NegativeOne, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(-MinNormal, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(-MaxSubnormal, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(-NFloat.Epsilon, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, AdditionOperatorsHelper.op_CheckedAddition(NFloat.NaN, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(Zero, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(NFloat.Epsilon, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(MaxSubnormal, One)); + AssertBitwiseEqual(One, AdditionOperatorsHelper.op_CheckedAddition(MinNormal, One)); + AssertBitwiseEqual(Two, AdditionOperatorsHelper.op_CheckedAddition(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, AdditionOperatorsHelper.op_CheckedAddition(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, AdditionOperatorsHelper.op_CheckedAddition(NFloat.PositiveInfinity, One)); } // @@ -209,7 +209,7 @@ public static void op_CheckedAdditionTest() [Fact] public static void AdditiveIdentityTest() { - AssertBitwiseEqual(PositiveZero, AdditiveIdentityHelper.AdditiveIdentity); + AssertBitwiseEqual(Zero, AdditiveIdentityHelper.AdditiveIdentity); } // @@ -227,11 +227,11 @@ public static void IsPow2Test() Assert.False(BinaryNumberHelper.IsPow2(-NFloat.Epsilon)); Assert.False(BinaryNumberHelper.IsPow2(NegativeZero)); Assert.False(BinaryNumberHelper.IsPow2(NFloat.NaN)); - Assert.False(BinaryNumberHelper.IsPow2(PositiveZero)); + Assert.False(BinaryNumberHelper.IsPow2(Zero)); Assert.False(BinaryNumberHelper.IsPow2(NFloat.Epsilon)); Assert.False(BinaryNumberHelper.IsPow2(MaxSubnormal)); Assert.True(BinaryNumberHelper.IsPow2(MinNormal)); - Assert.True(BinaryNumberHelper.IsPow2(PositiveOne)); + Assert.True(BinaryNumberHelper.IsPow2(One)); Assert.False(BinaryNumberHelper.IsPow2(NFloat.MaxValue)); Assert.False(BinaryNumberHelper.IsPow2(NFloat.PositiveInfinity)); } @@ -247,8 +247,8 @@ public static void Log2Test() AssertBitwiseEqual(NFloat.NaN, BinaryNumberHelper.Log2(-NFloat.Epsilon)); AssertBitwiseEqual(NFloat.NegativeInfinity, BinaryNumberHelper.Log2(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, BinaryNumberHelper.Log2(NFloat.NaN)); - AssertBitwiseEqual(NFloat.NegativeInfinity, BinaryNumberHelper.Log2(PositiveZero)); - AssertBitwiseEqual(PositiveZero, BinaryNumberHelper.Log2(PositiveOne)); + AssertBitwiseEqual(NFloat.NegativeInfinity, BinaryNumberHelper.Log2(Zero)); + AssertBitwiseEqual(Zero, BinaryNumberHelper.Log2(One)); AssertBitwiseEqual(NFloat.PositiveInfinity, BinaryNumberHelper.Log2(NFloat.PositiveInfinity)); if (Environment.Is64BitProcess) @@ -274,81 +274,81 @@ public static void Log2Test() [Fact] public static void op_GreaterThanTest() { - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.NegativeInfinity, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.MinValue, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NegativeOne, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(-MinNormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(-MaxSubnormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(-NFloat.Epsilon, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NegativeZero, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.NaN, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(PositiveZero, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.Epsilon, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(MaxSubnormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(MinNormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThan(PositiveOne, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_GreaterThan(NFloat.MaxValue, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_GreaterThan(NFloat.PositiveInfinity, PositiveOne)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.NegativeInfinity, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.MinValue, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NegativeOne, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(-MinNormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(-MaxSubnormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(-NFloat.Epsilon, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NegativeZero, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.NaN, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(Zero, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(NFloat.Epsilon, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(MaxSubnormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(MinNormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThan(One, One)); + Assert.True(ComparisonOperatorsHelper.op_GreaterThan(NFloat.MaxValue, One)); + Assert.True(ComparisonOperatorsHelper.op_GreaterThan(NFloat.PositiveInfinity, One)); } [Fact] public static void op_GreaterThanOrEqualTest() { - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.NegativeInfinity, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.MinValue, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NegativeOne, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(-MinNormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(-MaxSubnormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(-NFloat.Epsilon, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NegativeZero, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.NaN, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(PositiveZero, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.Epsilon, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(MaxSubnormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(MinNormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_GreaterThanOrEqual(PositiveOne, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.MaxValue, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.PositiveInfinity, PositiveOne)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.NegativeInfinity, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.MinValue, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NegativeOne, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(-MinNormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(-MaxSubnormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(-NFloat.Epsilon, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NegativeZero, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.NaN, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(Zero, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.Epsilon, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(MaxSubnormal, One)); + Assert.False(ComparisonOperatorsHelper.op_GreaterThanOrEqual(MinNormal, One)); + Assert.True(ComparisonOperatorsHelper.op_GreaterThanOrEqual(One, One)); + Assert.True(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.MaxValue, One)); + Assert.True(ComparisonOperatorsHelper.op_GreaterThanOrEqual(NFloat.PositiveInfinity, One)); } [Fact] public static void op_LessThanTest() { - Assert.True(ComparisonOperatorsHelper.op_LessThan(NFloat.NegativeInfinity, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(NFloat.MinValue, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(NegativeOne, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(-MinNormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(-MaxSubnormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(-NFloat.Epsilon, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(NegativeZero, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThan(NFloat.NaN, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(PositiveZero, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(NFloat.Epsilon, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(MaxSubnormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThan(MinNormal, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThan(PositiveOne, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThan(NFloat.MaxValue, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThan(NFloat.PositiveInfinity, PositiveOne)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(NFloat.NegativeInfinity, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(NFloat.MinValue, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(NegativeOne, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(-MinNormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(-MaxSubnormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(-NFloat.Epsilon, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(NegativeZero, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThan(NFloat.NaN, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(Zero, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(NFloat.Epsilon, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(MaxSubnormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThan(MinNormal, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThan(One, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThan(NFloat.MaxValue, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThan(NFloat.PositiveInfinity, One)); } [Fact] public static void op_LessThanOrEqualTest() { - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.NegativeInfinity, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.MinValue, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NegativeOne, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(-MinNormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(-MaxSubnormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(-NFloat.Epsilon, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NegativeZero, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.NaN, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(PositiveZero, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.Epsilon, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(MaxSubnormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(MinNormal, PositiveOne)); - Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(PositiveOne, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.MaxValue, PositiveOne)); - Assert.False(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.PositiveInfinity, PositiveOne)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.NegativeInfinity, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.MinValue, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NegativeOne, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(-MinNormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(-MaxSubnormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(-NFloat.Epsilon, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NegativeZero, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.NaN, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(Zero, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.Epsilon, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(MaxSubnormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(MinNormal, One)); + Assert.True(ComparisonOperatorsHelper.op_LessThanOrEqual(One, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.MaxValue, One)); + Assert.False(ComparisonOperatorsHelper.op_LessThanOrEqual(NFloat.PositiveInfinity, One)); } // @@ -366,11 +366,11 @@ public static void op_DecrementTest() AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(-NFloat.Epsilon)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, DecrementOperatorsHelper.op_Decrement(NFloat.NaN)); - AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(PositiveZero)); + AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(Zero)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(NFloat.Epsilon)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(MaxSubnormal)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_Decrement(MinNormal)); - AssertBitwiseEqual(PositiveZero, DecrementOperatorsHelper.op_Decrement(PositiveOne)); + AssertBitwiseEqual(Zero, DecrementOperatorsHelper.op_Decrement(One)); AssertBitwiseEqual(NFloat.MaxValue, DecrementOperatorsHelper.op_Decrement(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.PositiveInfinity, DecrementOperatorsHelper.op_Decrement(NFloat.PositiveInfinity)); } @@ -386,11 +386,11 @@ public static void op_CheckedDecrementTest() AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(-NFloat.Epsilon)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, DecrementOperatorsHelper.op_CheckedDecrement(NFloat.NaN)); - AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(PositiveZero)); + AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(Zero)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(NFloat.Epsilon)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(MaxSubnormal)); AssertBitwiseEqual(NegativeOne, DecrementOperatorsHelper.op_CheckedDecrement(MinNormal)); - AssertBitwiseEqual(PositiveZero, DecrementOperatorsHelper.op_CheckedDecrement(PositiveOne)); + AssertBitwiseEqual(Zero, DecrementOperatorsHelper.op_CheckedDecrement(One)); AssertBitwiseEqual(NFloat.MaxValue, DecrementOperatorsHelper.op_CheckedDecrement(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.PositiveInfinity, DecrementOperatorsHelper.op_CheckedDecrement(NFloat.PositiveInfinity)); } @@ -402,66 +402,66 @@ public static void op_CheckedDecrementTest() [Fact] public static void op_DivisionTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, DivisionOperatorsHelper.op_Division(NFloat.NegativeInfinity, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-0.5f), DivisionOperatorsHelper.op_Division(NegativeOne, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_Division(-NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_Division(NegativeZero, PositiveTwo)); - AssertBitwiseEqual(NFloat.NaN, DivisionOperatorsHelper.op_Division(NFloat.NaN, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, DivisionOperatorsHelper.op_Division(PositiveZero, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, DivisionOperatorsHelper.op_Division(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)0.5f, DivisionOperatorsHelper.op_Division(PositiveOne, PositiveTwo)); - AssertBitwiseEqual(NFloat.PositiveInfinity, DivisionOperatorsHelper.op_Division(NFloat.PositiveInfinity, PositiveTwo)); + AssertBitwiseEqual(NFloat.NegativeInfinity, DivisionOperatorsHelper.op_Division(NFloat.NegativeInfinity, Two)); + AssertBitwiseEqual((NFloat)(-0.5f), DivisionOperatorsHelper.op_Division(NegativeOne, Two)); + AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_Division(-NFloat.Epsilon, Two)); + AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_Division(NegativeZero, Two)); + AssertBitwiseEqual(NFloat.NaN, DivisionOperatorsHelper.op_Division(NFloat.NaN, Two)); + AssertBitwiseEqual(Zero, DivisionOperatorsHelper.op_Division(Zero, Two)); + AssertBitwiseEqual(Zero, DivisionOperatorsHelper.op_Division(NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)0.5f, DivisionOperatorsHelper.op_Division(One, Two)); + AssertBitwiseEqual(NFloat.PositiveInfinity, DivisionOperatorsHelper.op_Division(NFloat.PositiveInfinity, Two)); if (Environment.Is64BitProcess) { - AssertBitwiseEqual((NFloat)(-8.9884656743115785E+307), DivisionOperatorsHelper.op_Division(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_Division(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_Division(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_Division(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_Division(MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)8.9884656743115785E+307, DivisionOperatorsHelper.op_Division(NFloat.MaxValue, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-8.9884656743115785E+307), DivisionOperatorsHelper.op_Division(NFloat.MinValue, Two)); + AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_Division(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_Division(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_Division(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_Division(MinNormal, Two)); + AssertBitwiseEqual((NFloat)8.9884656743115785E+307, DivisionOperatorsHelper.op_Division(NFloat.MaxValue, Two)); } else { - AssertBitwiseEqual((NFloat)(-1.70141173E+38f), DivisionOperatorsHelper.op_Division(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_Division(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_Division(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_Division(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_Division(MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)1.70141173E+38f, DivisionOperatorsHelper.op_Division(NFloat.MaxValue, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-1.70141173E+38f), DivisionOperatorsHelper.op_Division(NFloat.MinValue, Two)); + AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_Division(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_Division(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_Division(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_Division(MinNormal, Two)); + AssertBitwiseEqual((NFloat)1.70141173E+38f, DivisionOperatorsHelper.op_Division(NFloat.MaxValue, Two)); } } [Fact] public static void op_CheckedDivisionTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, DivisionOperatorsHelper.op_CheckedDivision(NFloat.NegativeInfinity, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-0.5f), DivisionOperatorsHelper.op_CheckedDivision(NegativeOne, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_CheckedDivision(-NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_CheckedDivision(NegativeZero, PositiveTwo)); - AssertBitwiseEqual(NFloat.NaN, DivisionOperatorsHelper.op_CheckedDivision(NFloat.NaN, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, DivisionOperatorsHelper.op_CheckedDivision(PositiveZero, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, DivisionOperatorsHelper.op_CheckedDivision(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)0.5f, DivisionOperatorsHelper.op_CheckedDivision(PositiveOne, PositiveTwo)); - AssertBitwiseEqual(NFloat.PositiveInfinity, DivisionOperatorsHelper.op_CheckedDivision(NFloat.PositiveInfinity, PositiveTwo)); + AssertBitwiseEqual(NFloat.NegativeInfinity, DivisionOperatorsHelper.op_CheckedDivision(NFloat.NegativeInfinity, Two)); + AssertBitwiseEqual((NFloat)(-0.5f), DivisionOperatorsHelper.op_CheckedDivision(NegativeOne, Two)); + AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_CheckedDivision(-NFloat.Epsilon, Two)); + AssertBitwiseEqual(NegativeZero, DivisionOperatorsHelper.op_CheckedDivision(NegativeZero, Two)); + AssertBitwiseEqual(NFloat.NaN, DivisionOperatorsHelper.op_CheckedDivision(NFloat.NaN, Two)); + AssertBitwiseEqual(Zero, DivisionOperatorsHelper.op_CheckedDivision(Zero, Two)); + AssertBitwiseEqual(Zero, DivisionOperatorsHelper.op_CheckedDivision(NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)0.5f, DivisionOperatorsHelper.op_CheckedDivision(One, Two)); + AssertBitwiseEqual(NFloat.PositiveInfinity, DivisionOperatorsHelper.op_CheckedDivision(NFloat.PositiveInfinity, Two)); if (Environment.Is64BitProcess) { - AssertBitwiseEqual((NFloat)(-8.9884656743115785E+307), DivisionOperatorsHelper.op_CheckedDivision(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_CheckedDivision(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_CheckedDivision(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_CheckedDivision(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_CheckedDivision(MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)8.9884656743115785E+307, DivisionOperatorsHelper.op_CheckedDivision(NFloat.MaxValue, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-8.9884656743115785E+307), DivisionOperatorsHelper.op_CheckedDivision(NFloat.MinValue, Two)); + AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_CheckedDivision(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-1.1125369292536007E-308), DivisionOperatorsHelper.op_CheckedDivision(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_CheckedDivision(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)1.1125369292536007E-308, DivisionOperatorsHelper.op_CheckedDivision(MinNormal, Two)); + AssertBitwiseEqual((NFloat)8.9884656743115785E+307, DivisionOperatorsHelper.op_CheckedDivision(NFloat.MaxValue, Two)); } else { - AssertBitwiseEqual((NFloat)(-1.70141173E+38f), DivisionOperatorsHelper.op_CheckedDivision(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_CheckedDivision(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_CheckedDivision(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_CheckedDivision(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_CheckedDivision(MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)1.70141173E+38f, DivisionOperatorsHelper.op_CheckedDivision(NFloat.MaxValue, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-1.70141173E+38f), DivisionOperatorsHelper.op_CheckedDivision(NFloat.MinValue, Two)); + AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_CheckedDivision(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-5.87747175E-39f), DivisionOperatorsHelper.op_CheckedDivision(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_CheckedDivision(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)5.87747175E-39f, DivisionOperatorsHelper.op_CheckedDivision(MinNormal, Two)); + AssertBitwiseEqual((NFloat)1.70141173E+38f, DivisionOperatorsHelper.op_CheckedDivision(NFloat.MaxValue, Two)); } } @@ -472,41 +472,41 @@ public static void op_CheckedDivisionTest() [Fact] public static void op_EqualityTest() { - Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.NegativeInfinity, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.MinValue, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NegativeOne, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(-MinNormal, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(-MaxSubnormal, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(-NFloat.Epsilon, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NegativeZero, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.NaN, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(PositiveZero, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.Epsilon, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(MaxSubnormal, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(MinNormal, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Equality(PositiveOne, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.MaxValue, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.PositiveInfinity, PositiveOne)); + Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.NegativeInfinity, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.MinValue, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NegativeOne, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(-MinNormal, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(-MaxSubnormal, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(-NFloat.Epsilon, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NegativeZero, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.NaN, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(Zero, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.Epsilon, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(MaxSubnormal, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(MinNormal, One)); + Assert.True(EqualityOperatorsHelper.op_Equality(One, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.MaxValue, One)); + Assert.False(EqualityOperatorsHelper.op_Equality(NFloat.PositiveInfinity, One)); } [Fact] public static void op_InequalityTest() { - Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.NegativeInfinity, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.MinValue, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NegativeOne, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(-MinNormal, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(-MaxSubnormal, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(-NFloat.Epsilon, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NegativeZero, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.NaN, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(PositiveZero, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.Epsilon, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(MaxSubnormal, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(MinNormal, PositiveOne)); - Assert.False(EqualityOperatorsHelper.op_Inequality(PositiveOne, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.MaxValue, PositiveOne)); - Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.PositiveInfinity, PositiveOne)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.NegativeInfinity, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.MinValue, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NegativeOne, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(-MinNormal, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(-MaxSubnormal, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(-NFloat.Epsilon, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NegativeZero, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.NaN, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(Zero, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.Epsilon, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(MaxSubnormal, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(MinNormal, One)); + Assert.False(EqualityOperatorsHelper.op_Inequality(One, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.MaxValue, One)); + Assert.True(EqualityOperatorsHelper.op_Inequality(NFloat.PositiveInfinity, One)); } // @@ -526,11 +526,11 @@ public static void GetExponentByteCountTest() Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(-NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(NegativeZero)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(NFloat.NaN)); - Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(PositiveZero)); + Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(Zero)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(MaxSubnormal)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(MinNormal)); - Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(PositiveOne)); + Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(One)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(NFloat.MaxValue)); Assert.Equal(expected, FloatingPointHelper.GetExponentByteCount(NFloat.PositiveInfinity)); } @@ -546,7 +546,7 @@ public static void GetExponentShortestBitLengthTest() Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(-NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(NegativeZero)); Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(NFloat.NaN)); - Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(PositiveZero)); + Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(Zero)); Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(MaxSubnormal)); Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(MinNormal)); @@ -560,7 +560,7 @@ public static void GetExponentShortestBitLengthTest() expected = 0; Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(NegativeOne)); - Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(PositiveOne)); + Assert.Equal(expected, FloatingPointHelper.GetExponentShortestBitLength(One)); } [Fact] @@ -576,11 +576,11 @@ public static void GetSignificandByteCountTest() Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(-NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(NegativeZero)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(NFloat.NaN)); - Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(PositiveZero)); + Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(Zero)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(MaxSubnormal)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(MinNormal)); - Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(PositiveOne)); + Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(One)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(NFloat.MaxValue)); Assert.Equal(expected, FloatingPointHelper.GetSignificandByteCount(NFloat.PositiveInfinity)); } @@ -598,11 +598,11 @@ public static void GetSignificandBitLengthTest() Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(-NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(NegativeZero)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(NFloat.NaN)); - Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(PositiveZero)); + Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(Zero)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(NFloat.Epsilon)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(MaxSubnormal)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(MinNormal)); - Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(PositiveOne)); + Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(One)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(NFloat.MaxValue)); Assert.Equal(expected, FloatingPointHelper.GetSignificandBitLength(NFloat.PositiveInfinity)); } @@ -647,7 +647,7 @@ public static void TryWriteExponentBigEndianTest() Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0x04, 0x00 }, destination.ToArray()); // +1024 - Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(Zero, destination, out bytesWritten)); Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0xFC, 0x01 }, destination.ToArray()); // -1023 @@ -663,7 +663,7 @@ public static void TryWriteExponentBigEndianTest() Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0xFC, 0x02 }, destination.ToArray()); // -1022 - Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(One, destination, out bytesWritten)); Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00 }, destination.ToArray()); // +0 @@ -716,7 +716,7 @@ public static void TryWriteExponentBigEndianTest() Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x80 }, destination.ToArray()); // -128 - Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(Zero, destination, out bytesWritten)); Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x81 }, destination.ToArray()); // -127 @@ -732,7 +732,7 @@ public static void TryWriteExponentBigEndianTest() Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x82 }, destination.ToArray()); // -126 - Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentBigEndian(One, destination, out bytesWritten)); Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x00 }, destination.ToArray()); // +0 @@ -790,7 +790,7 @@ public static void TryWriteExponentLittleEndianTest() Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x04 }, destination.ToArray()); // +1024 - Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(Zero, destination, out bytesWritten)); Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0x01, 0xFC }, destination.ToArray()); // -1023 @@ -806,7 +806,7 @@ public static void TryWriteExponentLittleEndianTest() Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0x02, 0xFC }, destination.ToArray()); // -1022 - Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(One, destination, out bytesWritten)); Assert.Equal(2, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00 }, destination.ToArray()); // +0 @@ -859,7 +859,7 @@ public static void TryWriteExponentLittleEndianTest() Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x80 }, destination.ToArray()); // -128 - Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(Zero, destination, out bytesWritten)); Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x81 }, destination.ToArray()); // -127 @@ -875,7 +875,7 @@ public static void TryWriteExponentLittleEndianTest() Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x82 }, destination.ToArray()); // -126 - Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteExponentLittleEndian(One, destination, out bytesWritten)); Assert.Equal(1, bytesWritten); Assert.Equal(new byte[] { 0x00 }, destination.ToArray()); // +0 @@ -933,7 +933,7 @@ public static void TryWriteSignificandBigEndianTest() Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(Zero, destination, out bytesWritten)); Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); @@ -949,7 +949,7 @@ public static void TryWriteSignificandBigEndianTest() Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(One, destination, out bytesWritten)); Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); @@ -1002,7 +1002,7 @@ public static void TryWriteSignificandBigEndianTest() Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0xC0, 0x00, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(Zero, destination, out bytesWritten)); Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); @@ -1018,7 +1018,7 @@ public static void TryWriteSignificandBigEndianTest() Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x80, 0x00, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(One, destination, out bytesWritten)); Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x80, 0x00, 0x00 }, destination.ToArray()); @@ -1076,7 +1076,7 @@ public static void TryWriteSignificandLittleEndianTest() Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(Zero, destination, out bytesWritten)); Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); @@ -1092,7 +1092,7 @@ public static void TryWriteSignificandLittleEndianTest() Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(One, destination, out bytesWritten)); Assert.Equal(8, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 }, destination.ToArray()); @@ -1145,7 +1145,7 @@ public static void TryWriteSignificandLittleEndianTest() Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0xC0, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(PositiveZero, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(Zero, destination, out bytesWritten)); Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00 }, destination.ToArray()); @@ -1161,7 +1161,7 @@ public static void TryWriteSignificandLittleEndianTest() Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x80, 0x00 }, destination.ToArray()); - Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(PositiveOne, destination, out bytesWritten)); + Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(One, destination, out bytesWritten)); Assert.Equal(4, bytesWritten); Assert.Equal(new byte[] { 0x00, 0x00, 0x80, 0x00 }, destination.ToArray()); @@ -1188,17 +1188,17 @@ public static void op_IncrementTest() { AssertBitwiseEqual(NFloat.NegativeInfinity, IncrementOperatorsHelper.op_Increment(NFloat.NegativeInfinity)); AssertBitwiseEqual(NFloat.MinValue, IncrementOperatorsHelper.op_Increment(NFloat.MinValue)); - AssertBitwiseEqual(PositiveZero, IncrementOperatorsHelper.op_Increment(NegativeOne)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(-MinNormal)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(-MaxSubnormal)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(-NFloat.Epsilon)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(NegativeZero)); + AssertBitwiseEqual(Zero, IncrementOperatorsHelper.op_Increment(NegativeOne)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(-MinNormal)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(-MaxSubnormal)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(-NFloat.Epsilon)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, IncrementOperatorsHelper.op_Increment(NFloat.NaN)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(PositiveZero)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(NFloat.Epsilon)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(MaxSubnormal)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_Increment(MinNormal)); - AssertBitwiseEqual(PositiveTwo, IncrementOperatorsHelper.op_Increment(PositiveOne)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(Zero)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(NFloat.Epsilon)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(MaxSubnormal)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_Increment(MinNormal)); + AssertBitwiseEqual(Two, IncrementOperatorsHelper.op_Increment(One)); AssertBitwiseEqual(NFloat.MaxValue, IncrementOperatorsHelper.op_Increment(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.PositiveInfinity, IncrementOperatorsHelper.op_Increment(NFloat.PositiveInfinity)); } @@ -1208,17 +1208,17 @@ public static void op_CheckedIncrementTest() { AssertBitwiseEqual(NFloat.NegativeInfinity, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.NegativeInfinity)); AssertBitwiseEqual(NFloat.MinValue, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.MinValue)); - AssertBitwiseEqual(PositiveZero, IncrementOperatorsHelper.op_CheckedIncrement(NegativeOne)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(-MinNormal)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(-MaxSubnormal)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(-NFloat.Epsilon)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(NegativeZero)); + AssertBitwiseEqual(Zero, IncrementOperatorsHelper.op_CheckedIncrement(NegativeOne)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(-MinNormal)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(-MaxSubnormal)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(-NFloat.Epsilon)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.NaN)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(PositiveZero)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.Epsilon)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(MaxSubnormal)); - AssertBitwiseEqual(PositiveOne, IncrementOperatorsHelper.op_CheckedIncrement(MinNormal)); - AssertBitwiseEqual(PositiveTwo, IncrementOperatorsHelper.op_CheckedIncrement(PositiveOne)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(Zero)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.Epsilon)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(MaxSubnormal)); + AssertBitwiseEqual(One, IncrementOperatorsHelper.op_CheckedIncrement(MinNormal)); + AssertBitwiseEqual(Two, IncrementOperatorsHelper.op_CheckedIncrement(One)); AssertBitwiseEqual(NFloat.MaxValue, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.PositiveInfinity, IncrementOperatorsHelper.op_CheckedIncrement(NFloat.PositiveInfinity)); } @@ -1246,21 +1246,21 @@ public static void MinValueTest() [Fact] public static void op_ModulusTest() { - AssertBitwiseEqual(NFloat.NaN, ModulusOperatorsHelper.op_Modulus(NFloat.NegativeInfinity, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, ModulusOperatorsHelper.op_Modulus(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual(NegativeOne, ModulusOperatorsHelper.op_Modulus(NegativeOne, PositiveTwo)); - AssertBitwiseEqual(-MinNormal, ModulusOperatorsHelper.op_Modulus(-MinNormal, PositiveTwo)); - AssertBitwiseEqual(-MaxSubnormal, ModulusOperatorsHelper.op_Modulus(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual(-NFloat.Epsilon, ModulusOperatorsHelper.op_Modulus(-NFloat.Epsilon, PositiveTwo)); ; - AssertBitwiseEqual(NegativeZero, ModulusOperatorsHelper.op_Modulus(NegativeZero, PositiveTwo)); - AssertBitwiseEqual(NFloat.NaN, ModulusOperatorsHelper.op_Modulus(NFloat.NaN, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, ModulusOperatorsHelper.op_Modulus(PositiveZero, PositiveTwo)); - AssertBitwiseEqual(NFloat.Epsilon, ModulusOperatorsHelper.op_Modulus(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual(MaxSubnormal, ModulusOperatorsHelper.op_Modulus(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual(MinNormal, ModulusOperatorsHelper.op_Modulus(MinNormal, PositiveTwo)); - AssertBitwiseEqual(PositiveOne, ModulusOperatorsHelper.op_Modulus(PositiveOne, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, ModulusOperatorsHelper.op_Modulus(NFloat.MaxValue, PositiveTwo)); - AssertBitwiseEqual(NFloat.NaN, ModulusOperatorsHelper.op_Modulus(NFloat.PositiveInfinity, PositiveTwo)); + AssertBitwiseEqual(NFloat.NaN, ModulusOperatorsHelper.op_Modulus(NFloat.NegativeInfinity, Two)); + AssertBitwiseEqual(NegativeZero, ModulusOperatorsHelper.op_Modulus(NFloat.MinValue, Two)); + AssertBitwiseEqual(NegativeOne, ModulusOperatorsHelper.op_Modulus(NegativeOne, Two)); + AssertBitwiseEqual(-MinNormal, ModulusOperatorsHelper.op_Modulus(-MinNormal, Two)); + AssertBitwiseEqual(-MaxSubnormal, ModulusOperatorsHelper.op_Modulus(-MaxSubnormal, Two)); + AssertBitwiseEqual(-NFloat.Epsilon, ModulusOperatorsHelper.op_Modulus(-NFloat.Epsilon, Two)); ; + AssertBitwiseEqual(NegativeZero, ModulusOperatorsHelper.op_Modulus(NegativeZero, Two)); + AssertBitwiseEqual(NFloat.NaN, ModulusOperatorsHelper.op_Modulus(NFloat.NaN, Two)); + AssertBitwiseEqual(Zero, ModulusOperatorsHelper.op_Modulus(Zero, Two)); + AssertBitwiseEqual(NFloat.Epsilon, ModulusOperatorsHelper.op_Modulus(NFloat.Epsilon, Two)); + AssertBitwiseEqual(MaxSubnormal, ModulusOperatorsHelper.op_Modulus(MaxSubnormal, Two)); + AssertBitwiseEqual(MinNormal, ModulusOperatorsHelper.op_Modulus(MinNormal, Two)); + AssertBitwiseEqual(One, ModulusOperatorsHelper.op_Modulus(One, Two)); + AssertBitwiseEqual(Zero, ModulusOperatorsHelper.op_Modulus(NFloat.MaxValue, Two)); + AssertBitwiseEqual(NFloat.NaN, ModulusOperatorsHelper.op_Modulus(NFloat.PositiveInfinity, Two)); } // @@ -1270,7 +1270,7 @@ public static void op_ModulusTest() [Fact] public static void MultiplicativeIdentityTest() { - AssertBitwiseEqual(PositiveOne, MultiplicativeIdentityHelper.MultiplicativeIdentity); + AssertBitwiseEqual(One, MultiplicativeIdentityHelper.MultiplicativeIdentity); } // @@ -1280,66 +1280,66 @@ public static void MultiplicativeIdentityTest() [Fact] public static void op_MultiplyTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.NegativeInfinity, PositiveTwo)); - AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual(NegativeTwo, MultiplyOperatorsHelper.op_Multiply(NegativeOne, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, MultiplyOperatorsHelper.op_Multiply(NegativeZero, PositiveTwo)); - AssertBitwiseEqual(NFloat.NaN, MultiplyOperatorsHelper.op_Multiply(NFloat.NaN, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, MultiplyOperatorsHelper.op_Multiply(PositiveZero, PositiveTwo)); - AssertBitwiseEqual(PositiveTwo, MultiplyOperatorsHelper.op_Multiply(PositiveOne, PositiveTwo)); - AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.MaxValue, PositiveTwo)); - AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.PositiveInfinity, PositiveTwo)); + AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.NegativeInfinity, Two)); + AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.MinValue, Two)); + AssertBitwiseEqual(NegativeTwo, MultiplyOperatorsHelper.op_Multiply(NegativeOne, Two)); + AssertBitwiseEqual(NegativeZero, MultiplyOperatorsHelper.op_Multiply(NegativeZero, Two)); + AssertBitwiseEqual(NFloat.NaN, MultiplyOperatorsHelper.op_Multiply(NFloat.NaN, Two)); + AssertBitwiseEqual(Zero, MultiplyOperatorsHelper.op_Multiply(Zero, Two)); + AssertBitwiseEqual(Two, MultiplyOperatorsHelper.op_Multiply(One, Two)); + AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.MaxValue, Two)); + AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_Multiply(NFloat.PositiveInfinity, Two)); if (Environment.Is64BitProcess) { - AssertBitwiseEqual((NFloat)(-4.4501477170144028E-308), MultiplyOperatorsHelper.op_Multiply(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-4.4501477170144018E-308), MultiplyOperatorsHelper.op_Multiply(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-9.8813129168249309E-324), MultiplyOperatorsHelper.op_Multiply(-NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)9.8813129168249309E-324, MultiplyOperatorsHelper.op_Multiply(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)4.4501477170144018E-308, MultiplyOperatorsHelper.op_Multiply(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)4.4501477170144028E-308, MultiplyOperatorsHelper.op_Multiply(MinNormal, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-4.4501477170144028E-308), MultiplyOperatorsHelper.op_Multiply(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-4.4501477170144018E-308), MultiplyOperatorsHelper.op_Multiply(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)(-9.8813129168249309E-324), MultiplyOperatorsHelper.op_Multiply(-NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)9.8813129168249309E-324, MultiplyOperatorsHelper.op_Multiply(NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)4.4501477170144018E-308, MultiplyOperatorsHelper.op_Multiply(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)4.4501477170144028E-308, MultiplyOperatorsHelper.op_Multiply(MinNormal, Two)); } else { - AssertBitwiseEqual((NFloat)(-2.3509887E-38f), MultiplyOperatorsHelper.op_Multiply(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-2.35098842E-38f), MultiplyOperatorsHelper.op_Multiply(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-2.80259693E-45f), MultiplyOperatorsHelper.op_Multiply(-NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)2.80259693E-45f, MultiplyOperatorsHelper.op_Multiply(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)2.35098842E-38f, MultiplyOperatorsHelper.op_Multiply(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)2.3509887E-38f, MultiplyOperatorsHelper.op_Multiply(MinNormal, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-2.3509887E-38f), MultiplyOperatorsHelper.op_Multiply(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-2.35098842E-38f), MultiplyOperatorsHelper.op_Multiply(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)(-2.80259693E-45f), MultiplyOperatorsHelper.op_Multiply(-NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)2.80259693E-45f, MultiplyOperatorsHelper.op_Multiply(NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)2.35098842E-38f, MultiplyOperatorsHelper.op_Multiply(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)2.3509887E-38f, MultiplyOperatorsHelper.op_Multiply(MinNormal, Two)); } } [Fact] public static void op_CheckedMultiplyTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.NegativeInfinity, PositiveTwo)); - AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.MinValue, PositiveTwo)); - AssertBitwiseEqual(NegativeTwo, MultiplyOperatorsHelper.op_CheckedMultiply(NegativeOne, PositiveTwo)); - AssertBitwiseEqual(NegativeZero, MultiplyOperatorsHelper.op_CheckedMultiply(NegativeZero, PositiveTwo)); - AssertBitwiseEqual(NFloat.NaN, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.NaN, PositiveTwo)); - AssertBitwiseEqual(PositiveZero, MultiplyOperatorsHelper.op_CheckedMultiply(PositiveZero, PositiveTwo)); - AssertBitwiseEqual(PositiveTwo, MultiplyOperatorsHelper.op_CheckedMultiply(PositiveOne, PositiveTwo)); - AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.MaxValue, PositiveTwo)); - AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.PositiveInfinity, PositiveTwo)); + AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.NegativeInfinity, Two)); + AssertBitwiseEqual(NFloat.NegativeInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.MinValue, Two)); + AssertBitwiseEqual(NegativeTwo, MultiplyOperatorsHelper.op_CheckedMultiply(NegativeOne, Two)); + AssertBitwiseEqual(NegativeZero, MultiplyOperatorsHelper.op_CheckedMultiply(NegativeZero, Two)); + AssertBitwiseEqual(NFloat.NaN, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.NaN, Two)); + AssertBitwiseEqual(Zero, MultiplyOperatorsHelper.op_CheckedMultiply(Zero, Two)); + AssertBitwiseEqual(Two, MultiplyOperatorsHelper.op_CheckedMultiply(One, Two)); + AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.MaxValue, Two)); + AssertBitwiseEqual(NFloat.PositiveInfinity, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.PositiveInfinity, Two)); if (Environment.Is64BitProcess) { - AssertBitwiseEqual((NFloat)(-4.4501477170144028E-308), MultiplyOperatorsHelper.op_CheckedMultiply(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-4.4501477170144018E-308), MultiplyOperatorsHelper.op_CheckedMultiply(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-9.8813129168249309E-324), MultiplyOperatorsHelper.op_CheckedMultiply(-NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)9.8813129168249309E-324, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)4.4501477170144018E-308, MultiplyOperatorsHelper.op_CheckedMultiply(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)4.4501477170144028E-308, MultiplyOperatorsHelper.op_CheckedMultiply(MinNormal, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-4.4501477170144028E-308), MultiplyOperatorsHelper.op_CheckedMultiply(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-4.4501477170144018E-308), MultiplyOperatorsHelper.op_CheckedMultiply(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)(-9.8813129168249309E-324), MultiplyOperatorsHelper.op_CheckedMultiply(-NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)9.8813129168249309E-324, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)4.4501477170144018E-308, MultiplyOperatorsHelper.op_CheckedMultiply(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)4.4501477170144028E-308, MultiplyOperatorsHelper.op_CheckedMultiply(MinNormal, Two)); } else { - AssertBitwiseEqual((NFloat)(-2.3509887E-38f), MultiplyOperatorsHelper.op_CheckedMultiply(-MinNormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-2.35098842E-38f), MultiplyOperatorsHelper.op_CheckedMultiply(-MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)(-2.80259693E-45f), MultiplyOperatorsHelper.op_CheckedMultiply(-NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)2.80259693E-45f, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.Epsilon, PositiveTwo)); - AssertBitwiseEqual((NFloat)2.35098842E-38f, MultiplyOperatorsHelper.op_CheckedMultiply(MaxSubnormal, PositiveTwo)); - AssertBitwiseEqual((NFloat)2.3509887E-38f, MultiplyOperatorsHelper.op_CheckedMultiply(MinNormal, PositiveTwo)); + AssertBitwiseEqual((NFloat)(-2.3509887E-38f), MultiplyOperatorsHelper.op_CheckedMultiply(-MinNormal, Two)); + AssertBitwiseEqual((NFloat)(-2.35098842E-38f), MultiplyOperatorsHelper.op_CheckedMultiply(-MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)(-2.80259693E-45f), MultiplyOperatorsHelper.op_CheckedMultiply(-NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)2.80259693E-45f, MultiplyOperatorsHelper.op_CheckedMultiply(NFloat.Epsilon, Two)); + AssertBitwiseEqual((NFloat)2.35098842E-38f, MultiplyOperatorsHelper.op_CheckedMultiply(MaxSubnormal, Two)); + AssertBitwiseEqual((NFloat)2.3509887E-38f, MultiplyOperatorsHelper.op_CheckedMultiply(MinNormal, Two)); } } @@ -1350,61 +1350,101 @@ public static void op_CheckedMultiplyTest() [Fact] public static void ClampTest() { - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(NFloat.NegativeInfinity, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(NFloat.MinValue, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(NegativeOne, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(-MinNormal, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(-MaxSubnormal, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(-NFloat.Epsilon, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(NegativeZero, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(NFloat.NaN, NumberHelper.Clamp(NFloat.NaN, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(PositiveZero, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(NFloat.Epsilon, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(MaxSubnormal, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(MinNormal, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Clamp(PositiveOne, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual((NFloat)63.0f, NumberHelper.Clamp(NFloat.MaxValue, PositiveOne, (NFloat)63.0f)); - AssertBitwiseEqual((NFloat)63.0f, NumberHelper.Clamp(NFloat.PositiveInfinity, PositiveOne, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(NFloat.NegativeInfinity, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(NFloat.MinValue, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(NegativeOne, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(-MinNormal, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(-MaxSubnormal, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(-NFloat.Epsilon, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(NegativeZero, One, (NFloat)63.0f)); + AssertBitwiseEqual(NFloat.NaN, NumberHelper.Clamp(NFloat.NaN, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(Zero, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(NFloat.Epsilon, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(MaxSubnormal, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(MinNormal, One, (NFloat)63.0f)); + AssertBitwiseEqual(One, NumberHelper.Clamp(One, One, (NFloat)63.0f)); + AssertBitwiseEqual((NFloat)63.0f, NumberHelper.Clamp(NFloat.MaxValue, One, (NFloat)63.0f)); + AssertBitwiseEqual((NFloat)63.0f, NumberHelper.Clamp(NFloat.PositiveInfinity, One, (NFloat)63.0f)); } [Fact] public static void MaxTest() { - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(NFloat.NegativeInfinity, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(NFloat.MinValue, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(NegativeOne, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(-MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(-MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(-NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(NegativeZero, PositiveOne)); - AssertBitwiseEqual(NFloat.NaN, NumberHelper.Max(NFloat.NaN, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(PositiveZero, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Max(PositiveOne, PositiveOne)); - AssertBitwiseEqual(NFloat.MaxValue, NumberHelper.Max(NFloat.MaxValue, PositiveOne)); - AssertBitwiseEqual(NFloat.PositiveInfinity, NumberHelper.Max(NFloat.PositiveInfinity, PositiveOne)); + AssertBitwiseEqual(One, NumberHelper.Max(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(One, NumberHelper.Max(NFloat.MinValue, One)); + AssertBitwiseEqual(One, NumberHelper.Max(NegativeOne, One)); + AssertBitwiseEqual(One, NumberHelper.Max(-MinNormal, One)); + AssertBitwiseEqual(One, NumberHelper.Max(-MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberHelper.Max(-NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberHelper.Max(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, NumberHelper.Max(NFloat.NaN, One)); + AssertBitwiseEqual(One, NumberHelper.Max(Zero, One)); + AssertBitwiseEqual(One, NumberHelper.Max(NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberHelper.Max(MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberHelper.Max(MinNormal, One)); + AssertBitwiseEqual(One, NumberHelper.Max(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, NumberHelper.Max(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, NumberHelper.Max(NFloat.PositiveInfinity, One)); + } + + [Fact] + public static void MaxNumberTest() + { + AssertBitwiseEqual(One, NumberHelper.MaxNumber(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(NFloat.MinValue, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(NegativeOne, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(-MinNormal, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(-MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(-NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(NegativeZero, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(NFloat.NaN, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(Zero, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(MinNormal, One)); + AssertBitwiseEqual(One, NumberHelper.MaxNumber(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, NumberHelper.MaxNumber(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, NumberHelper.MaxNumber(NFloat.PositiveInfinity, One)); } [Fact] public static void MinTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, NumberHelper.Min(NFloat.NegativeInfinity, PositiveOne)); - AssertBitwiseEqual(NFloat.MinValue, NumberHelper.Min(NFloat.MinValue, PositiveOne)); - AssertBitwiseEqual(NegativeOne, NumberHelper.Min(NegativeOne, PositiveOne)); - AssertBitwiseEqual(-MinNormal, NumberHelper.Min(-MinNormal, PositiveOne)); - AssertBitwiseEqual(-MaxSubnormal, NumberHelper.Min(-MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(-NFloat.Epsilon, NumberHelper.Min(-NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(NegativeZero, NumberHelper.Min(NegativeZero, PositiveOne)); - AssertBitwiseEqual(NFloat.NaN, NumberHelper.Min(NFloat.NaN, PositiveOne)); - AssertBitwiseEqual(PositiveZero, NumberHelper.Min(PositiveZero, PositiveOne)); - AssertBitwiseEqual(NFloat.Epsilon, NumberHelper.Min(NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(MaxSubnormal, NumberHelper.Min(MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(MinNormal, NumberHelper.Min(MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Min(PositiveOne, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Min(NFloat.MaxValue, PositiveOne)); - AssertBitwiseEqual(PositiveOne, NumberHelper.Min(NFloat.PositiveInfinity, PositiveOne)); + AssertBitwiseEqual(NFloat.NegativeInfinity, NumberHelper.Min(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, NumberHelper.Min(NFloat.MinValue, One)); + AssertBitwiseEqual(NegativeOne, NumberHelper.Min(NegativeOne, One)); + AssertBitwiseEqual(-MinNormal, NumberHelper.Min(-MinNormal, One)); + AssertBitwiseEqual(-MaxSubnormal, NumberHelper.Min(-MaxSubnormal, One)); + AssertBitwiseEqual(-NFloat.Epsilon, NumberHelper.Min(-NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeZero, NumberHelper.Min(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, NumberHelper.Min(NFloat.NaN, One)); + AssertBitwiseEqual(Zero, NumberHelper.Min(Zero, One)); + AssertBitwiseEqual(NFloat.Epsilon, NumberHelper.Min(NFloat.Epsilon, One)); + AssertBitwiseEqual(MaxSubnormal, NumberHelper.Min(MaxSubnormal, One)); + AssertBitwiseEqual(MinNormal, NumberHelper.Min(MinNormal, One)); + AssertBitwiseEqual(One, NumberHelper.Min(One, One)); + AssertBitwiseEqual(One, NumberHelper.Min(NFloat.MaxValue, One)); + AssertBitwiseEqual(One, NumberHelper.Min(NFloat.PositiveInfinity, One)); + } + + [Fact] + public static void MinNumberTest() + { + AssertBitwiseEqual(NFloat.NegativeInfinity, NumberHelper.MinNumber(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, NumberHelper.MinNumber(NFloat.MinValue, One)); + AssertBitwiseEqual(NegativeOne, NumberHelper.MinNumber(NegativeOne, One)); + AssertBitwiseEqual(-MinNormal, NumberHelper.MinNumber(-MinNormal, One)); + AssertBitwiseEqual(-MaxSubnormal, NumberHelper.MinNumber(-MaxSubnormal, One)); + AssertBitwiseEqual(-NFloat.Epsilon, NumberHelper.MinNumber(-NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeZero, NumberHelper.MinNumber(NegativeZero, One)); + AssertBitwiseEqual(One, NumberHelper.MinNumber(NFloat.NaN, One)); + AssertBitwiseEqual(Zero, NumberHelper.MinNumber(Zero, One)); + AssertBitwiseEqual(NFloat.Epsilon, NumberHelper.MinNumber(NFloat.Epsilon, One)); + AssertBitwiseEqual(MaxSubnormal, NumberHelper.MinNumber(MaxSubnormal, One)); + AssertBitwiseEqual(MinNormal, NumberHelper.MinNumber(MinNormal, One)); + AssertBitwiseEqual(One, NumberHelper.MinNumber(One, One)); + AssertBitwiseEqual(One, NumberHelper.MinNumber(NFloat.MaxValue, One)); + AssertBitwiseEqual(One, NumberHelper.MinNumber(NFloat.PositiveInfinity, One)); } [Fact] @@ -1418,12 +1458,12 @@ public static void SignTest() Assert.Equal(-1, NumberHelper.Sign(-NFloat.Epsilon)); Assert.Equal(0, NumberHelper.Sign(NegativeZero)); - Assert.Equal(0, NumberHelper.Sign(PositiveZero)); + Assert.Equal(0, NumberHelper.Sign(Zero)); Assert.Equal(1, NumberHelper.Sign(NFloat.Epsilon)); Assert.Equal(1, NumberHelper.Sign(MaxSubnormal)); Assert.Equal(1, NumberHelper.Sign(MinNormal)); - Assert.Equal(1, NumberHelper.Sign(PositiveOne)); + Assert.Equal(1, NumberHelper.Sign(One)); Assert.Equal(1, NumberHelper.Sign(NFloat.MaxValue)); Assert.Equal(1, NumberHelper.Sign(NFloat.PositiveInfinity)); @@ -1437,13 +1477,19 @@ public static void SignTest() [Fact] public static void OneTest() { - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.One); + AssertBitwiseEqual(One, NumberBaseHelper.One); + } + + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); } [Fact] public static void ZeroTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.Zero); + AssertBitwiseEqual(Zero, NumberBaseHelper.Zero); } [Fact] @@ -1451,17 +1497,17 @@ public static void AbsTest() { AssertBitwiseEqual(NFloat.PositiveInfinity, NumberBaseHelper.Abs(NFloat.NegativeInfinity)); AssertBitwiseEqual(NFloat.MaxValue, NumberBaseHelper.Abs(NFloat.MinValue)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.Abs(NegativeOne)); + AssertBitwiseEqual(One, NumberBaseHelper.Abs(NegativeOne)); AssertBitwiseEqual(MinNormal, NumberBaseHelper.Abs(-MinNormal)); AssertBitwiseEqual(MaxSubnormal, NumberBaseHelper.Abs(-MaxSubnormal)); AssertBitwiseEqual(NFloat.Epsilon, NumberBaseHelper.Abs(-NFloat.Epsilon)); - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.Abs(NegativeZero)); + AssertBitwiseEqual(Zero, NumberBaseHelper.Abs(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, NumberBaseHelper.Abs(NFloat.NaN)); - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.Abs(PositiveZero)); + AssertBitwiseEqual(Zero, NumberBaseHelper.Abs(Zero)); AssertBitwiseEqual(NFloat.Epsilon, NumberBaseHelper.Abs(NFloat.Epsilon)); AssertBitwiseEqual(MaxSubnormal, NumberBaseHelper.Abs(MaxSubnormal)); AssertBitwiseEqual(MinNormal, NumberBaseHelper.Abs(MinNormal)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.Abs(PositiveOne)); + AssertBitwiseEqual(One, NumberBaseHelper.Abs(One)); AssertBitwiseEqual(NFloat.MaxValue, NumberBaseHelper.Abs(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.PositiveInfinity, NumberBaseHelper.Abs(NFloat.PositiveInfinity)); } @@ -1469,8 +1515,8 @@ public static void AbsTest() [Fact] public static void CreateCheckedFromByteTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x00)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x01)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x00)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x01)); AssertBitwiseEqual((NFloat)127.0f, NumberBaseHelper.CreateChecked(0x7F)); AssertBitwiseEqual((NFloat)128.0f, NumberBaseHelper.CreateChecked(0x80)); AssertBitwiseEqual((NFloat)255.0f, NumberBaseHelper.CreateChecked(0xFF)); @@ -1479,8 +1525,8 @@ public static void CreateCheckedFromByteTest() [Fact] public static void CreateCheckedFromCharTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked((char)0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked((char)0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked((char)0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked((char)0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateChecked((char)0x7FFF)); AssertBitwiseEqual((NFloat)32768.0f, NumberBaseHelper.CreateChecked((char)0x8000)); AssertBitwiseEqual((NFloat)65535.0f, NumberBaseHelper.CreateChecked((char)0xFFFF)); @@ -1489,8 +1535,8 @@ public static void CreateCheckedFromCharTest() [Fact] public static void CreateCheckedFromInt16Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateChecked(0x7FFF)); AssertBitwiseEqual((NFloat)(-32768.0f), NumberBaseHelper.CreateChecked(unchecked((short)0x8000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateChecked(unchecked((short)0xFFFF))); @@ -1499,8 +1545,8 @@ public static void CreateCheckedFromInt16Test() [Fact] public static void CreateCheckedFromInt32Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x00000001)); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateChecked(unchecked((int)0xFFFFFFFF))); if (Environment.Is64BitProcess) @@ -1518,8 +1564,8 @@ public static void CreateCheckedFromInt32Test() [Fact] public static void CreateCheckedFromInt64Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x0000000000000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x0000000000000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x0000000000000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x0000000000000001)); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateChecked(unchecked(unchecked((long)0xFFFFFFFFFFFFFFFF)))); if (Environment.Is64BitProcess) @@ -1539,16 +1585,16 @@ public static void CreateCheckedFromIntPtrTest() { if (Environment.Is64BitProcess) { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(unchecked((nint)0x0000000000000000))); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(unchecked((nint)0x0000000000000001))); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(unchecked((nint)0x0000000000000000))); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(unchecked((nint)0x0000000000000001))); AssertBitwiseEqual((NFloat)9223372036854775807.0, NumberBaseHelper.CreateChecked(unchecked((nint)0x7FFFFFFFFFFFFFFF))); AssertBitwiseEqual((NFloat)(-9223372036854775808.0), NumberBaseHelper.CreateChecked(unchecked((nint)0x8000000000000000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateChecked(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked((nint)0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked((nint)0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked((nint)0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked((nint)0x00000001)); AssertBitwiseEqual((NFloat)2147483647.0f, NumberBaseHelper.CreateChecked((nint)0x7FFFFFFF)); AssertBitwiseEqual((NFloat)(-2147483648.0f), NumberBaseHelper.CreateChecked(unchecked((nint)0x80000000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateChecked(unchecked((nint)0xFFFFFFFF))); @@ -1558,8 +1604,8 @@ public static void CreateCheckedFromIntPtrTest() [Fact] public static void CreateCheckedFromSByteTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x00)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x01)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x00)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x01)); AssertBitwiseEqual((NFloat)127.0f, NumberBaseHelper.CreateChecked(0x7F)); AssertBitwiseEqual((NFloat)(-128.0f), NumberBaseHelper.CreateChecked(unchecked((sbyte)0x80))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateChecked(unchecked((sbyte)0xFF))); @@ -1568,8 +1614,8 @@ public static void CreateCheckedFromSByteTest() [Fact] public static void CreateCheckedFromUInt16Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateChecked(0x7FFF)); AssertBitwiseEqual((NFloat)32768.0f, NumberBaseHelper.CreateChecked(0x8000)); AssertBitwiseEqual((NFloat)65535.0f, NumberBaseHelper.CreateChecked(0xFFFF)); @@ -1578,8 +1624,8 @@ public static void CreateCheckedFromUInt16Test() [Fact] public static void CreateCheckedFromUInt32Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x00000001)); if (Environment.Is64BitProcess) { @@ -1598,8 +1644,8 @@ public static void CreateCheckedFromUInt32Test() [Fact] public static void CreateCheckedFromUInt64Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(0x0000000000000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(0x0000000000000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(0x0000000000000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(0x0000000000000001)); if (Environment.Is64BitProcess) { @@ -1620,8 +1666,8 @@ public static void CreateCheckedFromUIntPtrTest() { if (Environment.Is64BitProcess) { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked(unchecked((nuint)0x0000000000000000))); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked(unchecked((nuint)0x0000000000000001))); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked(unchecked((nuint)0x0000000000000000))); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked(unchecked((nuint)0x0000000000000001))); AssertBitwiseEqual((NFloat)9223372036854775807.0, NumberBaseHelper.CreateChecked(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); // https://github.com/dotnet/roslyn/issues/60714 @@ -1630,8 +1676,8 @@ public static void CreateCheckedFromUIntPtrTest() } else { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateChecked((nuint)0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateChecked((nuint)0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateChecked((nuint)0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateChecked((nuint)0x00000001)); AssertBitwiseEqual((NFloat)2147483647.0f, NumberBaseHelper.CreateChecked((nuint)0x7FFFFFFF)); // https://github.com/dotnet/roslyn/issues/60714 @@ -1643,8 +1689,8 @@ public static void CreateCheckedFromUIntPtrTest() [Fact] public static void CreateSaturatingFromByteTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x00)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x01)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x00)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x01)); AssertBitwiseEqual((NFloat)127.0f, NumberBaseHelper.CreateSaturating(0x7F)); AssertBitwiseEqual((NFloat)128.0f, NumberBaseHelper.CreateSaturating(0x80)); AssertBitwiseEqual((NFloat)255.0f, NumberBaseHelper.CreateSaturating(0xFF)); @@ -1653,8 +1699,8 @@ public static void CreateSaturatingFromByteTest() [Fact] public static void CreateSaturatingFromCharTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating((char)0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating((char)0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating((char)0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating((char)0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateSaturating((char)0x7FFF)); AssertBitwiseEqual((NFloat)32768.0f, NumberBaseHelper.CreateSaturating((char)0x8000)); AssertBitwiseEqual((NFloat)65535.0f, NumberBaseHelper.CreateSaturating((char)0xFFFF)); @@ -1663,8 +1709,8 @@ public static void CreateSaturatingFromCharTest() [Fact] public static void CreateSaturatingFromInt16Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateSaturating(0x7FFF)); AssertBitwiseEqual((NFloat)(-32768.0f), NumberBaseHelper.CreateSaturating(unchecked((short)0x8000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateSaturating(unchecked((short)0xFFFF))); @@ -1673,8 +1719,8 @@ public static void CreateSaturatingFromInt16Test() [Fact] public static void CreateSaturatingFromInt32Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x00000001)); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateSaturating(unchecked((int)0xFFFFFFFF))); if (Environment.Is64BitProcess) @@ -1692,8 +1738,8 @@ public static void CreateSaturatingFromInt32Test() [Fact] public static void CreateSaturatingFromInt64Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x0000000000000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x0000000000000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x0000000000000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x0000000000000001)); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateSaturating(unchecked(unchecked((long)0xFFFFFFFFFFFFFFFF)))); if (Environment.Is64BitProcess) @@ -1713,16 +1759,16 @@ public static void CreateSaturatingFromIntPtrTest() { if (Environment.Is64BitProcess) { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(unchecked((nint)0x0000000000000000))); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(unchecked((nint)0x0000000000000001))); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(unchecked((nint)0x0000000000000000))); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(unchecked((nint)0x0000000000000001))); AssertBitwiseEqual((NFloat)9223372036854775807.0, NumberBaseHelper.CreateSaturating(unchecked((nint)0x7FFFFFFFFFFFFFFF))); AssertBitwiseEqual((NFloat)(-9223372036854775808.0), NumberBaseHelper.CreateSaturating(unchecked((nint)0x8000000000000000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateSaturating(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating((nint)0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating((nint)0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating((nint)0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating((nint)0x00000001)); AssertBitwiseEqual((NFloat)2147483647.0f, NumberBaseHelper.CreateSaturating((nint)0x7FFFFFFF)); AssertBitwiseEqual((NFloat)(-2147483648.0f), NumberBaseHelper.CreateSaturating(unchecked((nint)0x80000000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateSaturating(unchecked((nint)0xFFFFFFFF))); @@ -1732,8 +1778,8 @@ public static void CreateSaturatingFromIntPtrTest() [Fact] public static void CreateSaturatingFromSByteTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x00)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x01)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x00)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x01)); AssertBitwiseEqual((NFloat)127.0f, NumberBaseHelper.CreateSaturating(0x7F)); AssertBitwiseEqual((NFloat)(-128.0f), NumberBaseHelper.CreateSaturating(unchecked((sbyte)0x80))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateSaturating(unchecked((sbyte)0xFF))); @@ -1742,8 +1788,8 @@ public static void CreateSaturatingFromSByteTest() [Fact] public static void CreateSaturatingFromUInt16Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateSaturating(0x7FFF)); AssertBitwiseEqual((NFloat)32768.0f, NumberBaseHelper.CreateSaturating(0x8000)); AssertBitwiseEqual((NFloat)65535.0f, NumberBaseHelper.CreateSaturating(0xFFFF)); @@ -1752,8 +1798,8 @@ public static void CreateSaturatingFromUInt16Test() [Fact] public static void CreateSaturatingFromUInt32Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x00000001)); if (Environment.Is64BitProcess) { @@ -1772,8 +1818,8 @@ public static void CreateSaturatingFromUInt32Test() [Fact] public static void CreateSaturatingFromUInt64Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(0x0000000000000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(0x0000000000000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(0x0000000000000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(0x0000000000000001)); if (Environment.Is64BitProcess) { @@ -1794,8 +1840,8 @@ public static void CreateSaturatingFromUIntPtrTest() { if (Environment.Is64BitProcess) { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating(unchecked((nuint)0x0000000000000000))); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating(unchecked((nuint)0x0000000000000001))); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating(unchecked((nuint)0x0000000000000000))); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating(unchecked((nuint)0x0000000000000001))); AssertBitwiseEqual((NFloat)9223372036854775807.0, NumberBaseHelper.CreateSaturating(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); // https://github.com/dotnet/roslyn/issues/60714 @@ -1804,8 +1850,8 @@ public static void CreateSaturatingFromUIntPtrTest() } else { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateSaturating((nuint)0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateSaturating((nuint)0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateSaturating((nuint)0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateSaturating((nuint)0x00000001)); AssertBitwiseEqual((NFloat)2147483647.0f, NumberBaseHelper.CreateSaturating((nuint)0x7FFFFFFF)); // https://github.com/dotnet/roslyn/issues/60714 @@ -1817,8 +1863,8 @@ public static void CreateSaturatingFromUIntPtrTest() [Fact] public static void CreateTruncatingFromByteTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x00)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x01)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x00)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x01)); AssertBitwiseEqual((NFloat)127.0f, NumberBaseHelper.CreateTruncating(0x7F)); AssertBitwiseEqual((NFloat)128.0f, NumberBaseHelper.CreateTruncating(0x80)); AssertBitwiseEqual((NFloat)255.0f, NumberBaseHelper.CreateTruncating(0xFF)); @@ -1827,8 +1873,8 @@ public static void CreateTruncatingFromByteTest() [Fact] public static void CreateTruncatingFromCharTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating((char)0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating((char)0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating((char)0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating((char)0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateTruncating((char)0x7FFF)); AssertBitwiseEqual((NFloat)32768.0f, NumberBaseHelper.CreateTruncating((char)0x8000)); AssertBitwiseEqual((NFloat)65535.0f, NumberBaseHelper.CreateTruncating((char)0xFFFF)); @@ -1837,8 +1883,8 @@ public static void CreateTruncatingFromCharTest() [Fact] public static void CreateTruncatingFromInt16Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateTruncating(0x7FFF)); AssertBitwiseEqual((NFloat)(-32768.0f), NumberBaseHelper.CreateTruncating(unchecked((short)0x8000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateTruncating(unchecked((short)0xFFFF))); @@ -1847,8 +1893,8 @@ public static void CreateTruncatingFromInt16Test() [Fact] public static void CreateTruncatingFromInt32Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x00000001)); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateTruncating(unchecked((int)0xFFFFFFFF))); if (Environment.Is64BitProcess) @@ -1866,8 +1912,8 @@ public static void CreateTruncatingFromInt32Test() [Fact] public static void CreateTruncatingFromInt64Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x0000000000000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x0000000000000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x0000000000000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x0000000000000001)); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateTruncating(unchecked(unchecked((long)0xFFFFFFFFFFFFFFFF)))); if (Environment.Is64BitProcess) @@ -1887,16 +1933,16 @@ public static void CreateTruncatingFromIntPtrTest() { if (Environment.Is64BitProcess) { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(unchecked((nint)0x0000000000000000))); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(unchecked((nint)0x0000000000000001))); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(unchecked((nint)0x0000000000000000))); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(unchecked((nint)0x0000000000000001))); AssertBitwiseEqual((NFloat)9223372036854775807.0, NumberBaseHelper.CreateTruncating(unchecked((nint)0x7FFFFFFFFFFFFFFF))); AssertBitwiseEqual((NFloat)(-9223372036854775808.0), NumberBaseHelper.CreateTruncating(unchecked((nint)0x8000000000000000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateTruncating(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating((nint)0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating((nint)0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating((nint)0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating((nint)0x00000001)); AssertBitwiseEqual((NFloat)2147483647.0f, NumberBaseHelper.CreateTruncating((nint)0x7FFFFFFF)); AssertBitwiseEqual((NFloat)(-2147483648.0f), NumberBaseHelper.CreateTruncating(unchecked((nint)0x80000000))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateTruncating(unchecked((nint)0xFFFFFFFF))); @@ -1906,8 +1952,8 @@ public static void CreateTruncatingFromIntPtrTest() [Fact] public static void CreateTruncatingFromSByteTest() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x00)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x01)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x00)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x01)); AssertBitwiseEqual((NFloat)127.0f, NumberBaseHelper.CreateTruncating(0x7F)); AssertBitwiseEqual((NFloat)(-128.0f), NumberBaseHelper.CreateTruncating(unchecked((sbyte)0x80))); AssertBitwiseEqual(NegativeOne, NumberBaseHelper.CreateTruncating(unchecked((sbyte)0xFF))); @@ -1916,8 +1962,8 @@ public static void CreateTruncatingFromSByteTest() [Fact] public static void CreateTruncatingFromUInt16Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x0000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x0001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x0000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x0001)); AssertBitwiseEqual((NFloat)32767.0f, NumberBaseHelper.CreateTruncating(0x7FFF)); AssertBitwiseEqual((NFloat)32768.0f, NumberBaseHelper.CreateTruncating(0x8000)); AssertBitwiseEqual((NFloat)65535.0f, NumberBaseHelper.CreateTruncating(0xFFFF)); @@ -1926,8 +1972,8 @@ public static void CreateTruncatingFromUInt16Test() [Fact] public static void CreateTruncatingFromUInt32Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x00000001)); if (Environment.Is64BitProcess) { @@ -1946,8 +1992,8 @@ public static void CreateTruncatingFromUInt32Test() [Fact] public static void CreateTruncatingFromUInt64Test() { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(0x0000000000000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(0x0000000000000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(0x0000000000000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(0x0000000000000001)); if (Environment.Is64BitProcess) { @@ -1968,8 +2014,8 @@ public static void CreateTruncatingFromUIntPtrTest() { if (Environment.Is64BitProcess) { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating(unchecked((nuint)0x0000000000000000))); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating(unchecked((nuint)0x0000000000000001))); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating(unchecked((nuint)0x0000000000000000))); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating(unchecked((nuint)0x0000000000000001))); AssertBitwiseEqual((NFloat)9223372036854775807.0, NumberBaseHelper.CreateTruncating(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); // https://github.com/dotnet/roslyn/issues/60714 @@ -1978,8 +2024,8 @@ public static void CreateTruncatingFromUIntPtrTest() } else { - AssertBitwiseEqual(PositiveZero, NumberBaseHelper.CreateTruncating((nuint)0x00000000)); - AssertBitwiseEqual(PositiveOne, NumberBaseHelper.CreateTruncating((nuint)0x00000001)); + AssertBitwiseEqual(Zero, NumberBaseHelper.CreateTruncating((nuint)0x00000000)); + AssertBitwiseEqual(One, NumberBaseHelper.CreateTruncating((nuint)0x00000001)); AssertBitwiseEqual((NFloat)2147483647.0f, NumberBaseHelper.CreateTruncating((nuint)0x7FFFFFFF)); // https://github.com/dotnet/roslyn/issues/60714 @@ -1988,16 +2034,436 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsCanonical(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(NegativeOne)); + Assert.True(NumberBaseHelper.IsCanonical(-MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(NegativeZero)); + Assert.True(NumberBaseHelper.IsCanonical(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsCanonical(Zero)); + Assert.True(NumberBaseHelper.IsCanonical(NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(One)); + Assert.True(NumberBaseHelper.IsCanonical(NFloat.MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsComplexNumber(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(NegativeOne)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(NegativeZero)); + Assert.False(NumberBaseHelper.IsComplexNumber(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsComplexNumber(Zero)); + Assert.False(NumberBaseHelper.IsComplexNumber(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(One)); + Assert.False(NumberBaseHelper.IsComplexNumber(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.False(NumberBaseHelper.IsEvenInteger(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsEvenInteger(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(NegativeOne)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsEvenInteger(NegativeZero)); + Assert.False(NumberBaseHelper.IsEvenInteger(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsEvenInteger(Zero)); + Assert.False(NumberBaseHelper.IsEvenInteger(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(One)); + Assert.True(NumberBaseHelper.IsEvenInteger(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsFiniteTest() + { + Assert.False(NumberBaseHelper.IsFinite(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsFinite(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsFinite(NegativeOne)); + Assert.True(NumberBaseHelper.IsFinite(-MinNormal)); + Assert.True(NumberBaseHelper.IsFinite(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsFinite(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsFinite(NegativeZero)); + Assert.False(NumberBaseHelper.IsFinite(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsFinite(Zero)); + Assert.True(NumberBaseHelper.IsFinite(NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsFinite(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsFinite(MinNormal)); + Assert.True(NumberBaseHelper.IsFinite(One)); + Assert.True(NumberBaseHelper.IsFinite(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsFinite(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NegativeOne)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NegativeZero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Zero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(One)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsInfinityTest() + { + Assert.True(NumberBaseHelper.IsInfinity(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsInfinity(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsInfinity(NegativeOne)); + Assert.False(NumberBaseHelper.IsInfinity(-MinNormal)); + Assert.False(NumberBaseHelper.IsInfinity(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInfinity(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsInfinity(NegativeZero)); + Assert.False(NumberBaseHelper.IsInfinity(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsInfinity(Zero)); + Assert.False(NumberBaseHelper.IsInfinity(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsInfinity(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInfinity(MinNormal)); + Assert.False(NumberBaseHelper.IsInfinity(One)); + Assert.False(NumberBaseHelper.IsInfinity(NFloat.MaxValue)); + Assert.True(NumberBaseHelper.IsInfinity(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsIntegerTest() + { + Assert.False(NumberBaseHelper.IsInteger(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsInteger(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsInteger(NegativeOne)); + Assert.False(NumberBaseHelper.IsInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsInteger(NegativeZero)); + Assert.False(NumberBaseHelper.IsInteger(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsInteger(Zero)); + Assert.False(NumberBaseHelper.IsInteger(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsInteger(One)); + Assert.True(NumberBaseHelper.IsInteger(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsInteger(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsNaNTest() + { + Assert.False(NumberBaseHelper.IsNaN(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsNaN(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsNaN(NegativeOne)); + Assert.False(NumberBaseHelper.IsNaN(-MinNormal)); + Assert.False(NumberBaseHelper.IsNaN(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsNaN(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNaN(NegativeZero)); + Assert.True(NumberBaseHelper.IsNaN(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsNaN(Zero)); + Assert.False(NumberBaseHelper.IsNaN(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNaN(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsNaN(MinNormal)); + Assert.False(NumberBaseHelper.IsNaN(One)); + Assert.False(NumberBaseHelper.IsNaN(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsNaN(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsNegativeTest() + { + Assert.True(NumberBaseHelper.IsNegative(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsNegative(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsNegative(NegativeOne)); + Assert.True(NumberBaseHelper.IsNegative(-MinNormal)); + Assert.True(NumberBaseHelper.IsNegative(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsNegative(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsNegative(NegativeZero)); + Assert.True(NumberBaseHelper.IsNegative(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsNegative(Zero)); + Assert.False(NumberBaseHelper.IsNegative(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNegative(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsNegative(MinNormal)); + Assert.False(NumberBaseHelper.IsNegative(One)); + Assert.False(NumberBaseHelper.IsNegative(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsNegative(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsNegativeInfinityTest() + { + Assert.True(NumberBaseHelper.IsNegativeInfinity(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NegativeOne)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(-MinNormal)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NegativeZero)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(Zero)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(MinNormal)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(One)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsNormalTest() + { + Assert.False(NumberBaseHelper.IsNormal(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsNormal(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsNormal(NegativeOne)); + Assert.True(NumberBaseHelper.IsNormal(-MinNormal)); + Assert.False(NumberBaseHelper.IsNormal(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsNormal(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNormal(NegativeZero)); + Assert.False(NumberBaseHelper.IsNormal(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsNormal(Zero)); + Assert.False(NumberBaseHelper.IsNormal(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsNormal(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsNormal(MinNormal)); + Assert.True(NumberBaseHelper.IsNormal(One)); + Assert.True(NumberBaseHelper.IsNormal(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsNormal(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsOddInteger(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(NegativeOne)); + Assert.False(NumberBaseHelper.IsOddInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(NegativeZero)); + Assert.False(NumberBaseHelper.IsOddInteger(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsOddInteger(Zero)); + Assert.False(NumberBaseHelper.IsOddInteger(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsOddInteger(One)); + Assert.False(NumberBaseHelper.IsOddInteger(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.False(NumberBaseHelper.IsPositive(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsPositive(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsPositive(NegativeOne)); + Assert.False(NumberBaseHelper.IsPositive(-MinNormal)); + Assert.False(NumberBaseHelper.IsPositive(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositive(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsPositive(NegativeZero)); + Assert.False(NumberBaseHelper.IsPositive(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsPositive(Zero)); + Assert.True(NumberBaseHelper.IsPositive(NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsPositive(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsPositive(MinNormal)); + Assert.True(NumberBaseHelper.IsPositive(One)); + Assert.True(NumberBaseHelper.IsPositive(NFloat.MaxValue)); + Assert.True(NumberBaseHelper.IsPositive(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsPositiveInfinityTest() + { + Assert.False(NumberBaseHelper.IsPositiveInfinity(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(NegativeOne)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(-MinNormal)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(NegativeZero)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(Zero)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(MinNormal)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(One)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(NFloat.MaxValue)); + Assert.True(NumberBaseHelper.IsPositiveInfinity(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(NFloat.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsRealNumber(NFloat.MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(NegativeOne)); + Assert.True(NumberBaseHelper.IsRealNumber(-MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(NegativeZero)); + Assert.False(NumberBaseHelper.IsRealNumber(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsRealNumber(Zero)); + Assert.True(NumberBaseHelper.IsRealNumber(NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(One)); + Assert.True(NumberBaseHelper.IsRealNumber(NFloat.MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsSubnormalTest() + { + Assert.False(NumberBaseHelper.IsSubnormal(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsSubnormal(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsSubnormal(NegativeOne)); + Assert.False(NumberBaseHelper.IsSubnormal(-MinNormal)); + Assert.True(NumberBaseHelper.IsSubnormal(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsSubnormal(-NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsSubnormal(NegativeZero)); + Assert.False(NumberBaseHelper.IsSubnormal(NFloat.NaN)); + Assert.False(NumberBaseHelper.IsSubnormal(Zero)); + Assert.True(NumberBaseHelper.IsSubnormal(NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsSubnormal(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsSubnormal(MinNormal)); + Assert.False(NumberBaseHelper.IsSubnormal(One)); + Assert.False(NumberBaseHelper.IsSubnormal(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsSubnormal(NFloat.PositiveInfinity)); + } + + [Fact] + public static void IsZeroTest() + { + Assert.False(NumberBaseHelper.IsZero(NFloat.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsZero(NFloat.MinValue)); + Assert.False(NumberBaseHelper.IsZero(NegativeOne)); + Assert.False(NumberBaseHelper.IsZero(-MinNormal)); + Assert.False(NumberBaseHelper.IsZero(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(-NFloat.Epsilon)); + Assert.True(NumberBaseHelper.IsZero(NegativeZero)); + Assert.False(NumberBaseHelper.IsZero(NFloat.NaN)); + Assert.True(NumberBaseHelper.IsZero(Zero)); + Assert.False(NumberBaseHelper.IsZero(NFloat.Epsilon)); + Assert.False(NumberBaseHelper.IsZero(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(MinNormal)); + Assert.False(NumberBaseHelper.IsZero(One)); + Assert.False(NumberBaseHelper.IsZero(NFloat.MaxValue)); + Assert.False(NumberBaseHelper.IsZero(NFloat.PositiveInfinity)); + } + + [Fact] + public static void MaxMagnitudeTest() + { + AssertBitwiseEqual(NFloat.NegativeInfinity, NumberBaseHelper.MaxMagnitude(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, NumberBaseHelper.MaxMagnitude(NFloat.MinValue, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(NegativeOne, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(-MinNormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(-MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(-NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, NumberBaseHelper.MaxMagnitude(NFloat.NaN, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(Zero, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(MinNormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitude(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, NumberBaseHelper.MaxMagnitude(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, NumberBaseHelper.MaxMagnitude(NFloat.PositiveInfinity, One)); + } + + [Fact] + public static void MaxMagnitudeNumberTest() + { + AssertBitwiseEqual(NFloat.NegativeInfinity, NumberBaseHelper.MaxMagnitudeNumber(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, NumberBaseHelper.MaxMagnitudeNumber(NFloat.MinValue, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(NegativeOne, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(-MinNormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(-MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(-NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(NegativeZero, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(NFloat.NaN, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(Zero, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(NFloat.Epsilon, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(MaxSubnormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(MinNormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MaxMagnitudeNumber(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, NumberBaseHelper.MaxMagnitudeNumber(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, NumberBaseHelper.MaxMagnitudeNumber(NFloat.PositiveInfinity, One)); + } + + [Fact] + public static void MinMagnitudeTest() + { + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitude(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitude(NFloat.MinValue, One)); + AssertBitwiseEqual(NegativeOne, NumberBaseHelper.MinMagnitude(NegativeOne, One)); + AssertBitwiseEqual(-MinNormal, NumberBaseHelper.MinMagnitude(-MinNormal, One)); + AssertBitwiseEqual(-MaxSubnormal, NumberBaseHelper.MinMagnitude(-MaxSubnormal, One)); + AssertBitwiseEqual(-NFloat.Epsilon, NumberBaseHelper.MinMagnitude(-NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeZero, NumberBaseHelper.MinMagnitude(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, NumberBaseHelper.MinMagnitude(NFloat.NaN, One)); + AssertBitwiseEqual(Zero, NumberBaseHelper.MinMagnitude(Zero, One)); + AssertBitwiseEqual(NFloat.Epsilon, NumberBaseHelper.MinMagnitude(NFloat.Epsilon, One)); + AssertBitwiseEqual(MaxSubnormal, NumberBaseHelper.MinMagnitude(MaxSubnormal, One)); + AssertBitwiseEqual(MinNormal, NumberBaseHelper.MinMagnitude(MinNormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitude(One, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitude(NFloat.MaxValue, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitude(NFloat.PositiveInfinity, One)); + } + + [Fact] + public static void MinMagnitudeNumberTest() + { + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitudeNumber(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitudeNumber(NFloat.MinValue, One)); + AssertBitwiseEqual(NegativeOne, NumberBaseHelper.MinMagnitudeNumber(NegativeOne, One)); + AssertBitwiseEqual(-MinNormal, NumberBaseHelper.MinMagnitudeNumber(-MinNormal, One)); + AssertBitwiseEqual(-MaxSubnormal, NumberBaseHelper.MinMagnitudeNumber(-MaxSubnormal, One)); + AssertBitwiseEqual(-NFloat.Epsilon, NumberBaseHelper.MinMagnitudeNumber(-NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeZero, NumberBaseHelper.MinMagnitudeNumber(NegativeZero, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitudeNumber(NFloat.NaN, One)); + AssertBitwiseEqual(Zero, NumberBaseHelper.MinMagnitudeNumber(Zero, One)); + AssertBitwiseEqual(NFloat.Epsilon, NumberBaseHelper.MinMagnitudeNumber(NFloat.Epsilon, One)); + AssertBitwiseEqual(MaxSubnormal, NumberBaseHelper.MinMagnitudeNumber(MaxSubnormal, One)); + AssertBitwiseEqual(MinNormal, NumberBaseHelper.MinMagnitudeNumber(MinNormal, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitudeNumber(One, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitudeNumber(NFloat.MaxValue, One)); + AssertBitwiseEqual(One, NumberBaseHelper.MinMagnitudeNumber(NFloat.PositiveInfinity, One)); + } + [Fact] public static void TryCreateFromByteTest() { NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x00, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x01, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(0x7F, out result)); Assert.Equal((NFloat)127.0f, result); @@ -2015,10 +2481,10 @@ public static void TryCreateFromCharTest() NFloat result; Assert.True(NumberBaseHelper.TryCreate((char)0x0000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate((char)0x0001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate((char)0x7FFF, out result)); Assert.Equal((NFloat)32767.0f, result); @@ -2036,10 +2502,10 @@ public static void TryCreateFromInt16Test() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x0000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x0001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(0x7FFF, out result)); Assert.Equal((NFloat)32767.0f, result); @@ -2057,10 +2523,10 @@ public static void TryCreateFromInt32Test() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x00000000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x00000001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(unchecked((int)0xFFFFFFFF), out result)); Assert.Equal(NegativeOne, result); @@ -2089,10 +2555,10 @@ public static void TryCreateFromInt64Test() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x0000000000000000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x0000000000000001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(unchecked(unchecked((long)0xFFFFFFFFFFFFFFFF)), out result)); Assert.Equal(NegativeOne, result); @@ -2123,10 +2589,10 @@ public static void TryCreateFromIntPtrTest() if (Environment.Is64BitProcess) { Assert.True(NumberBaseHelper.TryCreate(unchecked((nint)0x0000000000000000), out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(unchecked((nint)0x0000000000000001), out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(unchecked((nint)0x7FFFFFFFFFFFFFFF), out result)); Assert.Equal((NFloat)9223372036854775807.0, result); @@ -2140,10 +2606,10 @@ public static void TryCreateFromIntPtrTest() else { Assert.True(NumberBaseHelper.TryCreate((nint)0x00000000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate((nint)0x00000001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate((nint)0x7FFFFFFF, out result)); Assert.Equal((NFloat)2147483647.0f, result); @@ -2162,10 +2628,10 @@ public static void TryCreateFromSByteTest() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x00, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x01, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(0x7F, out result)); Assert.Equal((NFloat)127.0f, result); @@ -2183,10 +2649,10 @@ public static void TryCreateFromUInt16Test() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x0000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x0001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(0x7FFF, out result)); Assert.Equal((NFloat)32767.0f, result); @@ -2204,10 +2670,10 @@ public static void TryCreateFromUInt32Test() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x00000000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x00000001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); if (Environment.Is64BitProcess) { @@ -2239,10 +2705,10 @@ public static void TryCreateFromUInt64Test() NFloat result; Assert.True(NumberBaseHelper.TryCreate(0x0000000000000000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(0x0000000000000001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); if (Environment.Is64BitProcess) { @@ -2276,10 +2742,10 @@ public static void TryCreateFromUIntPtrTest() if (Environment.Is64BitProcess) { Assert.True(NumberBaseHelper.TryCreate(unchecked((nuint)0x0000000000000000), out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate(unchecked((nuint)0x0000000000000001), out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate(unchecked((nuint)0x7FFFFFFFFFFFFFFF), out result)); Assert.Equal((NFloat)9223372036854775807.0, result); @@ -2294,10 +2760,10 @@ public static void TryCreateFromUIntPtrTest() else { Assert.True(NumberBaseHelper.TryCreate((nuint)0x00000000, out result)); - Assert.Equal(PositiveZero, result); + Assert.Equal(Zero, result); Assert.True(NumberBaseHelper.TryCreate((nuint)0x00000001, out result)); - Assert.Equal(PositiveOne, result); + Assert.Equal(One, result); Assert.True(NumberBaseHelper.TryCreate((nuint)0x7FFFFFFF, out result)); Assert.Equal((NFloat)2147483647.0f, result); @@ -2328,41 +2794,41 @@ public static void NegativeOneTest() [Fact] public static void op_SubtractionTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, SubtractionOperatorsHelper.op_Subtraction(NFloat.NegativeInfinity, PositiveOne)); - AssertBitwiseEqual(NFloat.MinValue, SubtractionOperatorsHelper.op_Subtraction(NFloat.MinValue, PositiveOne)); - AssertBitwiseEqual(NegativeTwo, SubtractionOperatorsHelper.op_Subtraction(NegativeOne, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(-MinNormal, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(-MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(-NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(NegativeZero, PositiveOne)); - AssertBitwiseEqual(NFloat.NaN, SubtractionOperatorsHelper.op_Subtraction(NFloat.NaN, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(PositiveZero, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveZero, SubtractionOperatorsHelper.op_Subtraction(PositiveOne, PositiveOne)); - AssertBitwiseEqual(NFloat.MaxValue, SubtractionOperatorsHelper.op_Subtraction(NFloat.MaxValue, PositiveOne)); - AssertBitwiseEqual(NFloat.PositiveInfinity, SubtractionOperatorsHelper.op_Subtraction(NFloat.PositiveInfinity, PositiveOne)); + AssertBitwiseEqual(NFloat.NegativeInfinity, SubtractionOperatorsHelper.op_Subtraction(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, SubtractionOperatorsHelper.op_Subtraction(NFloat.MinValue, One)); + AssertBitwiseEqual(NegativeTwo, SubtractionOperatorsHelper.op_Subtraction(NegativeOne, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(-MinNormal, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(-MaxSubnormal, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(-NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, SubtractionOperatorsHelper.op_Subtraction(NFloat.NaN, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(Zero, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(MaxSubnormal, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_Subtraction(MinNormal, One)); + AssertBitwiseEqual(Zero, SubtractionOperatorsHelper.op_Subtraction(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, SubtractionOperatorsHelper.op_Subtraction(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, SubtractionOperatorsHelper.op_Subtraction(NFloat.PositiveInfinity, One)); } [Fact] public static void op_CheckedSubtractionTest() { - AssertBitwiseEqual(NFloat.NegativeInfinity, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.NegativeInfinity, PositiveOne)); - AssertBitwiseEqual(NFloat.MinValue, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.MinValue, PositiveOne)); - AssertBitwiseEqual(NegativeTwo, SubtractionOperatorsHelper.op_CheckedSubtraction(NegativeOne, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(-MinNormal, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(-MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(-NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(NegativeZero, PositiveOne)); - AssertBitwiseEqual(NFloat.NaN, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.NaN, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(PositiveZero, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.Epsilon, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(MaxSubnormal, PositiveOne)); - AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(MinNormal, PositiveOne)); - AssertBitwiseEqual(PositiveZero, SubtractionOperatorsHelper.op_CheckedSubtraction(PositiveOne, PositiveOne)); - AssertBitwiseEqual(NFloat.MaxValue, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.MaxValue, PositiveOne)); - AssertBitwiseEqual(NFloat.PositiveInfinity, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.PositiveInfinity, PositiveOne)); + AssertBitwiseEqual(NFloat.NegativeInfinity, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.NegativeInfinity, One)); + AssertBitwiseEqual(NFloat.MinValue, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.MinValue, One)); + AssertBitwiseEqual(NegativeTwo, SubtractionOperatorsHelper.op_CheckedSubtraction(NegativeOne, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(-MinNormal, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(-MaxSubnormal, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(-NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(NegativeZero, One)); + AssertBitwiseEqual(NFloat.NaN, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.NaN, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(Zero, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.Epsilon, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(MaxSubnormal, One)); + AssertBitwiseEqual(NegativeOne, SubtractionOperatorsHelper.op_CheckedSubtraction(MinNormal, One)); + AssertBitwiseEqual(Zero, SubtractionOperatorsHelper.op_CheckedSubtraction(One, One)); + AssertBitwiseEqual(NFloat.MaxValue, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.MaxValue, One)); + AssertBitwiseEqual(NFloat.PositiveInfinity, SubtractionOperatorsHelper.op_CheckedSubtraction(NFloat.PositiveInfinity, One)); } // @@ -2374,17 +2840,17 @@ public static void op_UnaryNegationTest() { AssertBitwiseEqual(NFloat.PositiveInfinity, UnaryNegationOperatorsHelper.op_UnaryNegation(NFloat.NegativeInfinity)); AssertBitwiseEqual(NFloat.MaxValue, UnaryNegationOperatorsHelper.op_UnaryNegation(NFloat.MinValue)); - AssertBitwiseEqual(PositiveOne, UnaryNegationOperatorsHelper.op_UnaryNegation(NegativeOne)); + AssertBitwiseEqual(One, UnaryNegationOperatorsHelper.op_UnaryNegation(NegativeOne)); AssertBitwiseEqual(MinNormal, UnaryNegationOperatorsHelper.op_UnaryNegation(-MinNormal)); AssertBitwiseEqual(MaxSubnormal, UnaryNegationOperatorsHelper.op_UnaryNegation(-MaxSubnormal)); AssertBitwiseEqual(NFloat.Epsilon, UnaryNegationOperatorsHelper.op_UnaryNegation(-NFloat.Epsilon)); - AssertBitwiseEqual(PositiveZero, UnaryNegationOperatorsHelper.op_UnaryNegation(NegativeZero)); + AssertBitwiseEqual(Zero, UnaryNegationOperatorsHelper.op_UnaryNegation(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, UnaryNegationOperatorsHelper.op_UnaryNegation(NFloat.NaN)); - AssertBitwiseEqual(NegativeZero, UnaryNegationOperatorsHelper.op_UnaryNegation(PositiveZero)); + AssertBitwiseEqual(NegativeZero, UnaryNegationOperatorsHelper.op_UnaryNegation(Zero)); AssertBitwiseEqual(-NFloat.Epsilon, UnaryNegationOperatorsHelper.op_UnaryNegation(NFloat.Epsilon)); AssertBitwiseEqual(-MaxSubnormal, UnaryNegationOperatorsHelper.op_UnaryNegation(MaxSubnormal)); AssertBitwiseEqual(-MinNormal, UnaryNegationOperatorsHelper.op_UnaryNegation(MinNormal)); - AssertBitwiseEqual(NegativeOne, UnaryNegationOperatorsHelper.op_UnaryNegation(PositiveOne)); + AssertBitwiseEqual(NegativeOne, UnaryNegationOperatorsHelper.op_UnaryNegation(One)); AssertBitwiseEqual(NFloat.MinValue, UnaryNegationOperatorsHelper.op_UnaryNegation(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.NegativeInfinity, UnaryNegationOperatorsHelper.op_UnaryNegation(NFloat.PositiveInfinity)); } @@ -2394,17 +2860,17 @@ public static void op_CheckedUnaryNegationTest() { AssertBitwiseEqual(NFloat.PositiveInfinity, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NFloat.NegativeInfinity)); AssertBitwiseEqual(NFloat.MaxValue, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NFloat.MinValue)); - AssertBitwiseEqual(PositiveOne, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NegativeOne)); + AssertBitwiseEqual(One, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NegativeOne)); AssertBitwiseEqual(MinNormal, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(-MinNormal)); AssertBitwiseEqual(MaxSubnormal, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(-MaxSubnormal)); AssertBitwiseEqual(NFloat.Epsilon, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(-NFloat.Epsilon)); - AssertBitwiseEqual(PositiveZero, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NegativeZero)); + AssertBitwiseEqual(Zero, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NFloat.NaN)); - AssertBitwiseEqual(NegativeZero, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(PositiveZero)); + AssertBitwiseEqual(NegativeZero, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(Zero)); AssertBitwiseEqual(-NFloat.Epsilon, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NFloat.Epsilon)); AssertBitwiseEqual(-MaxSubnormal, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(MaxSubnormal)); AssertBitwiseEqual(-MinNormal, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(MinNormal)); - AssertBitwiseEqual(NegativeOne, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(PositiveOne)); + AssertBitwiseEqual(NegativeOne, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(One)); AssertBitwiseEqual(NFloat.MinValue, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.NegativeInfinity, UnaryNegationOperatorsHelper.op_CheckedUnaryNegation(NFloat.PositiveInfinity)); } @@ -2424,11 +2890,11 @@ public static void op_UnaryPlusTest() AssertBitwiseEqual(-NFloat.Epsilon, UnaryPlusOperatorsHelper.op_UnaryPlus(-NFloat.Epsilon)); AssertBitwiseEqual(NegativeZero, UnaryPlusOperatorsHelper.op_UnaryPlus(NegativeZero)); AssertBitwiseEqual(NFloat.NaN, UnaryPlusOperatorsHelper.op_UnaryPlus(NFloat.NaN)); - AssertBitwiseEqual(PositiveZero, UnaryPlusOperatorsHelper.op_UnaryPlus(PositiveZero)); + AssertBitwiseEqual(Zero, UnaryPlusOperatorsHelper.op_UnaryPlus(Zero)); AssertBitwiseEqual(NFloat.Epsilon, UnaryPlusOperatorsHelper.op_UnaryPlus(NFloat.Epsilon)); AssertBitwiseEqual(MaxSubnormal, UnaryPlusOperatorsHelper.op_UnaryPlus(MaxSubnormal)); AssertBitwiseEqual(MinNormal, UnaryPlusOperatorsHelper.op_UnaryPlus(MinNormal)); - AssertBitwiseEqual(PositiveOne, UnaryPlusOperatorsHelper.op_UnaryPlus(PositiveOne)); + AssertBitwiseEqual(One, UnaryPlusOperatorsHelper.op_UnaryPlus(One)); AssertBitwiseEqual(NFloat.MaxValue, UnaryPlusOperatorsHelper.op_UnaryPlus(NFloat.MaxValue)); AssertBitwiseEqual(NFloat.PositiveInfinity, UnaryPlusOperatorsHelper.op_UnaryPlus(NFloat.PositiveInfinity)); } diff --git a/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs b/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs index 4b7f8fefefa301..a7a99ca8c232f0 100644 --- a/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs +++ b/src/libraries/System.Runtime.Numerics/ref/System.Runtime.Numerics.cs @@ -31,6 +31,7 @@ namespace System.Numerics public int Sign { get { throw null; } } static System.Numerics.BigInteger System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static System.Numerics.BigInteger System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static System.Numerics.BigInteger System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static System.Numerics.BigInteger Zero { get { throw null; } } public static System.Numerics.BigInteger Abs(System.Numerics.BigInteger value) { throw null; } @@ -58,7 +59,10 @@ namespace System.Numerics public int GetByteCount(bool isUnsigned = false) { throw null; } public override int GetHashCode() { throw null; } public static System.Numerics.BigInteger GreatestCommonDivisor(System.Numerics.BigInteger left, System.Numerics.BigInteger right) { throw null; } + public static bool IsEvenInteger(System.Numerics.BigInteger value) { throw null; } public static bool IsNegative(System.Numerics.BigInteger value) { throw null; } + public static bool IsOddInteger(System.Numerics.BigInteger value) { throw null; } + public static bool IsPositive(System.Numerics.BigInteger value) { throw null; } public static bool IsPow2(System.Numerics.BigInteger value) { throw null; } public static System.Numerics.BigInteger LeadingZeroCount(System.Numerics.BigInteger value) { throw null; } public static double Log(System.Numerics.BigInteger value) { throw null; } @@ -193,13 +197,19 @@ namespace System.Numerics static System.Numerics.BigInteger System.Numerics.IDivisionOperators.operator checked /(System.Numerics.BigInteger left, System.Numerics.BigInteger right) { throw null; } static System.Numerics.BigInteger System.Numerics.IIncrementOperators.operator checked ++(System.Numerics.BigInteger value) { throw null; } static System.Numerics.BigInteger System.Numerics.IMultiplyOperators.operator checked *(System.Numerics.BigInteger left, System.Numerics.BigInteger right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(System.Numerics.BigInteger value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(System.Numerics.BigInteger value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(System.Numerics.BigInteger value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(System.Numerics.BigInteger value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(System.Numerics.BigInteger value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(System.Numerics.BigInteger value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(System.Numerics.BigInteger value) { throw null; } static System.Numerics.BigInteger System.Numerics.INumberBase.MaxMagnitudeNumber(System.Numerics.BigInteger x, System.Numerics.BigInteger y) { throw null; } static System.Numerics.BigInteger System.Numerics.INumberBase.MinMagnitudeNumber(System.Numerics.BigInteger x, System.Numerics.BigInteger y) { throw null; } static System.Numerics.BigInteger System.Numerics.INumber.MaxNumber(System.Numerics.BigInteger x, System.Numerics.BigInteger y) { throw null; } @@ -240,6 +250,7 @@ namespace System.Numerics static System.Numerics.Complex System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static System.Numerics.Complex System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static System.Numerics.Complex System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static System.Numerics.Complex System.Numerics.INumberBase.Zero { get { throw null; } } static System.Numerics.Complex System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static double Abs(System.Numerics.Complex value) { throw null; } @@ -263,9 +274,21 @@ namespace System.Numerics public static System.Numerics.Complex Exp(System.Numerics.Complex value) { throw null; } public static System.Numerics.Complex FromPolarCoordinates(double magnitude, double phase) { throw null; } public override int GetHashCode() { throw null; } + public static bool IsComplexNumber(System.Numerics.Complex value) { throw null; } + public static bool IsEvenInteger(System.Numerics.Complex value) { throw null; } public static bool IsFinite(System.Numerics.Complex value) { throw null; } + public static bool IsImaginaryNumber(System.Numerics.Complex value) { throw null; } public static bool IsInfinity(System.Numerics.Complex value) { throw null; } + public static bool IsInteger(System.Numerics.Complex value) { throw null; } public static bool IsNaN(System.Numerics.Complex value) { throw null; } + public static bool IsNegative(System.Numerics.Complex value) { throw null; } + public static bool IsNegativeInfinity(System.Numerics.Complex value) { throw null; } + public static bool IsNormal(System.Numerics.Complex value) { throw null; } + public static bool IsOddInteger(System.Numerics.Complex value) { throw null; } + public static bool IsPositive(System.Numerics.Complex value) { throw null; } + public static bool IsPositiveInfinity(System.Numerics.Complex value) { throw null; } + public static bool IsRealNumber(System.Numerics.Complex value) { throw null; } + public static bool IsSubnormal(System.Numerics.Complex value) { throw null; } public static System.Numerics.Complex Log(System.Numerics.Complex value) { throw null; } public static System.Numerics.Complex Log(System.Numerics.Complex value, double baseValue) { throw null; } public static System.Numerics.Complex Log10(System.Numerics.Complex value) { throw null; } @@ -328,11 +351,8 @@ namespace System.Numerics static System.Numerics.Complex System.Numerics.IIncrementOperators.operator checked ++(System.Numerics.Complex value) { throw null; } static System.Numerics.Complex System.Numerics.IMultiplyOperators.operator checked *(System.Numerics.Complex left, System.Numerics.Complex right) { throw null; } static System.Numerics.Complex System.Numerics.INumberBase.Abs(System.Numerics.Complex value) { throw null; } - static bool System.Numerics.INumberBase.IsNegative(System.Numerics.Complex value) { throw null; } - static bool System.Numerics.INumberBase.IsNegativeInfinity(System.Numerics.Complex value) { throw null; } - static bool System.Numerics.INumberBase.IsNormal(System.Numerics.Complex value) { throw null; } - static bool System.Numerics.INumberBase.IsPositiveInfinity(System.Numerics.Complex value) { throw null; } - static bool System.Numerics.INumberBase.IsSubnormal(System.Numerics.Complex value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(System.Numerics.Complex value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(System.Numerics.Complex value) { throw null; } static System.Numerics.Complex System.Numerics.INumberBase.MaxMagnitudeNumber(System.Numerics.Complex x, System.Numerics.Complex y) { throw null; } static System.Numerics.Complex System.Numerics.INumberBase.MinMagnitudeNumber(System.Numerics.Complex x, System.Numerics.Complex y) { throw null; } static System.Numerics.Complex System.Numerics.ISubtractionOperators.operator checked -(System.Numerics.Complex left, System.Numerics.Complex right) { throw null; } diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs index bb74e29bb6542c..e079da8ca7c497 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs @@ -3885,6 +3885,9 @@ static int INumber.Sign(BigInteger value) // INumberBase // + /// + static int INumberBase.Radix => 2; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BigInteger CreateChecked(TOther value) @@ -4101,12 +4104,36 @@ public static BigInteger CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(BigInteger value) => true; + + /// + static bool INumberBase.IsComplexNumber(BigInteger value) => false; + + /// + public static bool IsEvenInteger(BigInteger value) + { + value.AssertValid(); + + if (value._bits is null) + { + return (value._sign & 1) == 0; + } + return (value._bits[0] & 1) == 0; + } + /// static bool INumberBase.IsFinite(BigInteger value) => true; + /// + static bool INumberBase.IsImaginaryNumber(BigInteger value) => false; + /// static bool INumberBase.IsInfinity(BigInteger value) => false; + /// + static bool INumberBase.IsInteger(BigInteger value) => true; + /// static bool INumberBase.IsNaN(BigInteger value) => false; @@ -4123,12 +4150,41 @@ public static bool IsNegative(BigInteger value) /// static bool INumberBase.IsNormal(BigInteger value) => (value != 0); + /// + public static bool IsOddInteger(BigInteger value) + { + value.AssertValid(); + + if (value._bits is null) + { + return (value._sign & 1) != 0; + } + return (value._bits[0] & 1) != 0; + } + + /// + public static bool IsPositive(BigInteger value) + { + value.AssertValid(); + return value._sign >= 0; + } + /// static bool INumberBase.IsPositiveInfinity(BigInteger value) => false; + /// + static bool INumberBase.IsRealNumber(BigInteger value) => true; + /// static bool INumberBase.IsSubnormal(BigInteger value) => false; + /// + static bool INumberBase.IsZero(BigInteger value) + { + value.AssertValid(); + return value._sign == 0; + } + /// public static BigInteger MaxMagnitude(BigInteger x, BigInteger y) { diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs index c89c573b77aad1..9d67f3058e5f82 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs @@ -925,6 +925,9 @@ public static explicit operator Complex(decimal value) /// static Complex INumberBase.One => new Complex(1.0, 0.0); + /// + static int INumberBase.Radix => 2; + /// static Complex INumberBase.Zero => new Complex(0.0, 0.0); @@ -1135,8 +1138,23 @@ public static Complex CreateTruncating(TOther value) } } + /// + static bool INumberBase.IsCanonical(Complex value) => true; + + /// + public static bool IsComplexNumber(Complex value) => (value.m_real != 0.0) && (value.m_imaginary != 0.0); + + /// + public static bool IsEvenInteger(Complex value) => (value.m_imaginary == 0) && double.IsEvenInteger(value.m_real); + + /// + public static bool IsImaginaryNumber(Complex value) => (value.m_real == 0.0) && double.IsRealNumber(value.m_imaginary); + + /// + public static bool IsInteger(Complex value) => (value.m_imaginary == 0) && double.IsInteger(value.m_real); + /// - static bool INumberBase.IsNegative(Complex value) + public static bool IsNegative(Complex value) { // since complex numbers do not have a well-defined concept of // negative we report false if this value has an imaginary part @@ -1145,7 +1163,7 @@ static bool INumberBase.IsNegative(Complex value) } /// - static bool INumberBase.IsNegativeInfinity(Complex value) + public static bool IsNegativeInfinity(Complex value) { // since complex numbers do not have a well-defined concept of // negative we report false if this value has an imaginary part @@ -1154,7 +1172,7 @@ static bool INumberBase.IsNegativeInfinity(Complex value) } /// - static bool INumberBase.IsNormal(Complex value) + public static bool IsNormal(Complex value) { // much as IsFinite requires both part to be finite, we require both // part to be "normal" (finite, non-zero, and non-subnormal) to be true @@ -1163,8 +1181,20 @@ static bool INumberBase.IsNormal(Complex value) && ((value.m_imaginary == 0.0) || double.IsNormal(value.m_imaginary)); } + /// + public static bool IsOddInteger(Complex value) => (value.m_imaginary == 0) && double.IsOddInteger(value.m_real); + + /// + public static bool IsPositive(Complex value) + { + // since complex numbers do not have a well-defined concept of + // negative we report false if this value has an imaginary part + + return (value.m_imaginary == 0.0) && double.IsPositive(value.m_real); + } + /// - static bool INumberBase.IsPositiveInfinity(Complex value) + public static bool IsPositiveInfinity(Complex value) { // since complex numbers do not have a well-defined concept of // positive we report false if this value has an imaginary part @@ -1172,8 +1202,11 @@ static bool INumberBase.IsPositiveInfinity(Complex value) return (value.m_imaginary == 0.0) && double.IsPositiveInfinity(value.m_real); } + /// + public static bool IsRealNumber(Complex value) => (value.m_imaginary == 0.0) && double.IsRealNumber(value.m_real); + /// - static bool INumberBase.IsSubnormal(Complex value) + public static bool IsSubnormal(Complex value) { // much as IsInfinite allows either part to be infinite, we allow either // part to be "subnormal" (finite, non-zero, and non-normal) to be true @@ -1181,6 +1214,9 @@ static bool INumberBase.IsSubnormal(Complex value) return double.IsSubnormal(value.m_real) || double.IsSubnormal(value.m_imaginary); } + /// + static bool INumberBase.IsZero(Complex value) => (value.m_real == 0.0) && (value.m_imaginary == 0.0); + /// public static Complex MaxMagnitude(Complex x, Complex y) { diff --git a/src/libraries/System.Runtime.Numerics/tests/BigIntegerTests.GenericMath.cs b/src/libraries/System.Runtime.Numerics/tests/BigIntegerTests.GenericMath.cs index 55b06ca359a99c..889aa29edc337b 100644 --- a/src/libraries/System.Runtime.Numerics/tests/BigIntegerTests.GenericMath.cs +++ b/src/libraries/System.Runtime.Numerics/tests/BigIntegerTests.GenericMath.cs @@ -994,6 +994,12 @@ public static void OneTest() Assert.Equal(One, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1410,6 +1416,48 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(Zero)); + Assert.True(NumberBaseHelper.IsCanonical(One)); + Assert.True(NumberBaseHelper.IsCanonical(Int64MaxValue)); + + Assert.True(NumberBaseHelper.IsCanonical(Int64MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(NegativeOne)); + + Assert.True(NumberBaseHelper.IsCanonical(Int64MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsCanonical(UInt64MaxValue)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(Zero)); + Assert.False(NumberBaseHelper.IsComplexNumber(One)); + Assert.False(NumberBaseHelper.IsComplexNumber(Int64MaxValue)); + + Assert.False(NumberBaseHelper.IsComplexNumber(Int64MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(NegativeOne)); + + Assert.False(NumberBaseHelper.IsComplexNumber(Int64MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsComplexNumber(UInt64MaxValue)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger(Zero)); + Assert.False(NumberBaseHelper.IsEvenInteger(One)); + Assert.False(NumberBaseHelper.IsEvenInteger(Int64MaxValue)); + + Assert.True(NumberBaseHelper.IsEvenInteger(Int64MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(NegativeOne)); + + Assert.True(NumberBaseHelper.IsEvenInteger(Int64MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsEvenInteger(UInt64MaxValue)); + } + [Fact] public static void IsFiniteTest() { @@ -1424,6 +1472,20 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(UInt64MaxValue)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(Zero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(One)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Int64MaxValue)); + + Assert.False(NumberBaseHelper.IsImaginaryNumber(Int64MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NegativeOne)); + + Assert.False(NumberBaseHelper.IsImaginaryNumber(Int64MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(UInt64MaxValue)); + } + [Fact] public static void IsInfinityTest() { @@ -1438,6 +1500,20 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(UInt64MaxValue)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger(Zero)); + Assert.True(NumberBaseHelper.IsInteger(One)); + Assert.True(NumberBaseHelper.IsInteger(Int64MaxValue)); + + Assert.True(NumberBaseHelper.IsInteger(Int64MinValue)); + Assert.True(NumberBaseHelper.IsInteger(NegativeOne)); + + Assert.True(NumberBaseHelper.IsInteger(Int64MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsInteger(UInt64MaxValue)); + } + [Fact] public static void IsNaNTest() { @@ -1494,6 +1570,34 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(UInt64MaxValue)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(Zero)); + Assert.True(NumberBaseHelper.IsOddInteger(One)); + Assert.True(NumberBaseHelper.IsOddInteger(Int64MaxValue)); + + Assert.False(NumberBaseHelper.IsOddInteger(Int64MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(NegativeOne)); + + Assert.False(NumberBaseHelper.IsOddInteger(Int64MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsOddInteger(UInt64MaxValue)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive(Zero)); + Assert.True(NumberBaseHelper.IsPositive(One)); + Assert.True(NumberBaseHelper.IsPositive(Int64MaxValue)); + + Assert.False(NumberBaseHelper.IsPositive(Int64MinValue)); + Assert.False(NumberBaseHelper.IsPositive(NegativeOne)); + + Assert.True(NumberBaseHelper.IsPositive(Int64MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsPositive(UInt64MaxValue)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1508,6 +1612,20 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(UInt64MaxValue)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(Zero)); + Assert.True(NumberBaseHelper.IsRealNumber(One)); + Assert.True(NumberBaseHelper.IsRealNumber(Int64MaxValue)); + + Assert.True(NumberBaseHelper.IsRealNumber(Int64MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(NegativeOne)); + + Assert.True(NumberBaseHelper.IsRealNumber(Int64MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsRealNumber(UInt64MaxValue)); + } + [Fact] public static void IsSubnormalTest() { @@ -1522,6 +1640,20 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(UInt64MaxValue)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero(Zero)); + Assert.False(NumberBaseHelper.IsZero(One)); + Assert.False(NumberBaseHelper.IsZero(Int64MaxValue)); + + Assert.False(NumberBaseHelper.IsZero(Int64MinValue)); + Assert.False(NumberBaseHelper.IsZero(NegativeOne)); + + Assert.False(NumberBaseHelper.IsZero(Int64MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsZero(UInt64MaxValue)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime.Numerics/tests/ComplexTests.GenericMath.cs b/src/libraries/System.Runtime.Numerics/tests/ComplexTests.GenericMath.cs index 6735d64230ba8c..4425b15a9f04a9 100644 --- a/src/libraries/System.Runtime.Numerics/tests/ComplexTests.GenericMath.cs +++ b/src/libraries/System.Runtime.Numerics/tests/ComplexTests.GenericMath.cs @@ -257,6 +257,12 @@ public static void OneTest() AssertBitwiseEqual(1.0, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -691,6 +697,186 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsCanonical(double.MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(-1.0)); + Assert.True(NumberBaseHelper.IsCanonical(-MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(-0.0)); + Assert.True(NumberBaseHelper.IsCanonical(double.NaN)); + Assert.True(NumberBaseHelper.IsCanonical(0.0)); + Assert.True(NumberBaseHelper.IsCanonical(double.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(1.0)); + Assert.True(NumberBaseHelper.IsCanonical(double.MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(double.PositiveInfinity)); + + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, -1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, -0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, 0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, 1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-1.0, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, -1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, -0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, 0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, 1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(-0.0, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, -1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, -0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, double.NaN))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, 0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, 1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, -0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, 0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, 1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(0.0, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, -1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, -0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, 0.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, 1.0))); + Assert.True(NumberBaseHelper.IsCanonical(new Complex(1.0, double.PositiveInfinity))); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(-1.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(-0.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.NaN)); + Assert.False(NumberBaseHelper.IsComplexNumber(0.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(1.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.PositiveInfinity)); + + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, -1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, -0.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, 0.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, 1.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, -1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, double.NaN))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(-0.0, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, -0.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, 0.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, 1.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, -1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, double.NaN))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(0.0, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(1.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(1.0, -1.0))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(1.0, -0.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsComplexNumber(new Complex(1.0, 0.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(1.0, 1.0))); + Assert.True(NumberBaseHelper.IsComplexNumber(new Complex(1.0, double.PositiveInfinity))); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.False(NumberBaseHelper.IsEvenInteger(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsEvenInteger(double.MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1.0)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsEvenInteger(-0.0)); + Assert.False(NumberBaseHelper.IsEvenInteger(double.NaN)); + Assert.True(NumberBaseHelper.IsEvenInteger(0.0)); + Assert.False(NumberBaseHelper.IsEvenInteger(double.Epsilon)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.0)); + Assert.True(NumberBaseHelper.IsEvenInteger(double.MaxValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, -1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, -1.0))); + Assert.True(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsEvenInteger(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsEvenInteger(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, -1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsEvenInteger(new Complex(1.0, double.PositiveInfinity))); + } + [Fact] public static void IsFiniteTest() { @@ -751,6 +937,66 @@ public static void IsFiniteTest() Assert.False(NumberBaseHelper.IsFinite(new Complex(1.0, double.PositiveInfinity))); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-1.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsImaginaryNumber(-0.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.NaN)); + Assert.True(NumberBaseHelper.IsImaginaryNumber(0.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(1.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, -1.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-1.0, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, -1.0))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, 0.0))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, 1.0))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, double.NegativeInfinity))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, 0.0))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, 1.0))); + Assert.True(NumberBaseHelper.IsImaginaryNumber(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, -1.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(new Complex(1.0, double.PositiveInfinity))); + } + [Fact] public static void IsInfinityTest() { @@ -811,6 +1057,66 @@ public static void IsInfinityTest() Assert.True(NumberBaseHelper.IsInfinity(new Complex(1.0, double.PositiveInfinity))); } + [Fact] + public static void IsIntegerTest() + { + Assert.False(NumberBaseHelper.IsInteger(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsInteger(double.MinValue)); + Assert.True(NumberBaseHelper.IsInteger(-1.0)); + Assert.False(NumberBaseHelper.IsInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsInteger(-0.0)); + Assert.False(NumberBaseHelper.IsInteger(double.NaN)); + Assert.True(NumberBaseHelper.IsInteger(0.0)); + Assert.False(NumberBaseHelper.IsInteger(double.Epsilon)); + Assert.False(NumberBaseHelper.IsInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsInteger(1.0)); + Assert.True(NumberBaseHelper.IsInteger(double.MaxValue)); + Assert.False(NumberBaseHelper.IsInteger(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsInteger(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-1.0, -1.0))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsInteger(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-0.0, -1.0))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsInteger(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsInteger(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(1.0, -1.0))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsInteger(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsInteger(new Complex(1.0, double.PositiveInfinity))); + } + [Fact] public static void IsNaNTest() { @@ -1051,6 +1357,126 @@ public static void IsNormalTest() Assert.False(NumberBaseHelper.IsNormal(new Complex(1.0, double.PositiveInfinity))); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsOddInteger(double.MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(-1.0)); + Assert.False(NumberBaseHelper.IsOddInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(-0.0)); + Assert.False(NumberBaseHelper.IsOddInteger(double.NaN)); + Assert.False(NumberBaseHelper.IsOddInteger(0.0)); + Assert.False(NumberBaseHelper.IsOddInteger(double.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsOddInteger(1.0)); + Assert.False(NumberBaseHelper.IsOddInteger(double.MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-1.0, -1.0))); + Assert.True(NumberBaseHelper.IsOddInteger(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsOddInteger(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, -1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, double.NaN))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, -1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, double.NaN))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(1.0, -1.0))); + Assert.True(NumberBaseHelper.IsOddInteger(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsOddInteger(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsOddInteger(new Complex(1.0, double.PositiveInfinity))); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.False(NumberBaseHelper.IsPositive(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsPositive(double.MinValue)); + Assert.False(NumberBaseHelper.IsPositive(-1.0)); + Assert.False(NumberBaseHelper.IsPositive(-MinNormal)); + Assert.False(NumberBaseHelper.IsPositive(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositive(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsPositive(-0.0)); + Assert.False(NumberBaseHelper.IsPositive(double.NaN)); + Assert.True(NumberBaseHelper.IsPositive(0.0)); + Assert.True(NumberBaseHelper.IsPositive(double.Epsilon)); + Assert.True(NumberBaseHelper.IsPositive(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsPositive(MinNormal)); + Assert.True(NumberBaseHelper.IsPositive(1.0)); + Assert.True(NumberBaseHelper.IsPositive(double.MaxValue)); + Assert.True(NumberBaseHelper.IsPositive(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, -1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, -1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, double.NaN))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsPositive(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsPositive(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsPositive(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsPositive(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(1.0, -1.0))); + Assert.True(NumberBaseHelper.IsPositive(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsPositive(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsPositive(new Complex(1.0, double.PositiveInfinity))); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1111,6 +1537,66 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(new Complex(1.0, double.PositiveInfinity))); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsRealNumber(double.MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(-1.0)); + Assert.True(NumberBaseHelper.IsRealNumber(-MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(-0.0)); + Assert.False(NumberBaseHelper.IsRealNumber(double.NaN)); + Assert.True(NumberBaseHelper.IsRealNumber(0.0)); + Assert.True(NumberBaseHelper.IsRealNumber(double.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(1.0)); + Assert.True(NumberBaseHelper.IsRealNumber(double.MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-1.0, -1.0))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-0.0, -1.0))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(1.0, -1.0))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(1.0, double.NaN))); + Assert.True(NumberBaseHelper.IsRealNumber(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsRealNumber(new Complex(1.0, double.PositiveInfinity))); + } + [Fact] public static void IsSubnormalTest() { @@ -1171,6 +1657,66 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(new Complex(1.0, double.PositiveInfinity))); } + [Fact] + public static void IsZeroTest() + { + Assert.False(NumberBaseHelper.IsZero(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsZero(double.MinValue)); + Assert.False(NumberBaseHelper.IsZero(-1.0)); + Assert.False(NumberBaseHelper.IsZero(-MinNormal)); + Assert.False(NumberBaseHelper.IsZero(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsZero(-0.0)); + Assert.False(NumberBaseHelper.IsZero(double.NaN)); + Assert.True(NumberBaseHelper.IsZero(0.0)); + Assert.False(NumberBaseHelper.IsZero(double.Epsilon)); + Assert.False(NumberBaseHelper.IsZero(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(MinNormal)); + Assert.False(NumberBaseHelper.IsZero(1.0)); + Assert.False(NumberBaseHelper.IsZero(double.MaxValue)); + Assert.False(NumberBaseHelper.IsZero(double.PositiveInfinity)); + + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, -1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, -0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, 0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, 1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-1.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsZero(new Complex(-0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-0.0, -1.0))); + Assert.True(NumberBaseHelper.IsZero(new Complex(-0.0, -0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsZero(new Complex(-0.0, 0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-0.0, 1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(-0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, -1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, -0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, double.NaN))); + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, 0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, 1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(double.NaN, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsZero(new Complex(0.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsZero(new Complex(0.0, -1.0))); + Assert.True(NumberBaseHelper.IsZero(new Complex(0.0, -0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(0.0, double.NaN))); + Assert.True(NumberBaseHelper.IsZero(new Complex(0.0, 0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(0.0, 1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(0.0, double.PositiveInfinity))); + + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, double.NegativeInfinity))); + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, -1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, -0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, double.NaN))); + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, 0.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, 1.0))); + Assert.False(NumberBaseHelper.IsZero(new Complex(1.0, double.PositiveInfinity))); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index bcfaa53f8fa3fa..9aebff4f1e12a5 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -723,6 +723,7 @@ public static void SetByte(System.Array array, int index, byte value) { } static byte System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static byte System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static byte System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static byte System.Numerics.INumberBase.Zero { get { throw null; } } public static byte Clamp(byte value, byte min, byte max) { throw null; } public int CompareTo(byte value) { throw null; } @@ -735,6 +736,8 @@ public static void SetByte(System.Array array, int index, byte value) { } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(byte value) { throw null; } + public static bool IsOddInteger(byte value) { throw null; } public static bool IsPow2(byte value) { throw null; } public static byte LeadingZeroCount(byte value) { throw null; } public static byte Log2(byte value) { throw null; } @@ -791,14 +794,21 @@ public static void SetByte(System.Array array, int index, byte value) { } static byte System.Numerics.IMultiplyOperators.operator checked *(byte left, byte right) { throw null; } static byte System.Numerics.IMultiplyOperators.operator *(byte left, byte right) { throw null; } static byte System.Numerics.INumberBase.Abs(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(byte value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(byte value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(byte value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(byte value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(byte value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(byte value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(byte value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(byte value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(byte value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(byte value) { throw null; } static byte System.Numerics.INumberBase.MaxMagnitude(byte x, byte y) { throw null; } static byte System.Numerics.INumberBase.MaxMagnitudeNumber(byte x, byte y) { throw null; } static byte System.Numerics.INumberBase.MinMagnitude(byte x, byte y) { throw null; } @@ -845,6 +855,7 @@ public CannotUnloadAppDomainException(string? message, System.Exception? innerEx static char System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static char System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static char System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static char System.Numerics.INumberBase.Zero { get { throw null; } } public int CompareTo(char value) { throw null; } public int CompareTo(object? value) { throw null; } @@ -958,14 +969,23 @@ public CannotUnloadAppDomainException(string? message, System.Exception? innerEx static char System.Numerics.INumberBase.CreateChecked(TOther value) { throw null; } static char System.Numerics.INumberBase.CreateSaturating(TOther value) { throw null; } static char System.Numerics.INumberBase.CreateTruncating(TOther value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(char value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(char value) { throw null; } + static bool System.Numerics.INumberBase.IsEvenInteger(char value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(char value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(char value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(char value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(char value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(char value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(char value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(char value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(char value) { throw null; } + static bool System.Numerics.INumberBase.IsOddInteger(char value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(char value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(char value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(char value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(char value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(char value) { throw null; } static char System.Numerics.INumberBase.MaxMagnitude(char x, char y) { throw null; } static char System.Numerics.INumberBase.MaxMagnitudeNumber(char x, char y) { throw null; } static char System.Numerics.INumberBase.MinMagnitude(char x, char y) { throw null; } @@ -1857,6 +1877,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S static decimal System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static decimal System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static decimal System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static decimal System.Numerics.INumberBase.Zero { get { throw null; } } static decimal System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static decimal Abs(decimal value) { throw null; } @@ -1880,7 +1901,12 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static int GetBits(decimal d, System.Span destination) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsCanonical(decimal value) { throw null; } + public static bool IsEvenInteger(decimal value) { throw null; } + public static bool IsInteger(decimal value) { throw null; } public static bool IsNegative(decimal value) { throw null; } + public static bool IsOddInteger(decimal value) { throw null; } + public static bool IsPositive(decimal value) { throw null; } public static decimal Max(decimal x, decimal y) { throw null; } public static decimal MaxMagnitude(decimal x, decimal y) { throw null; } public static decimal Min(decimal x, decimal y) { throw null; } @@ -1973,13 +1999,17 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S bool System.Numerics.IFloatingPoint.TryWriteSignificandBigEndian(System.Span destination, out int bytesWritten) { throw null; } bool System.Numerics.IFloatingPoint.TryWriteSignificandLittleEndian(System.Span destination, out int bytesWritten) { throw null; } static decimal System.Numerics.IIncrementOperators.operator checked ++(decimal value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(decimal value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(decimal value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(decimal value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(decimal value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(decimal value) { throw null; } static decimal System.Numerics.INumberBase.MaxMagnitudeNumber(decimal x, decimal y) { throw null; } static decimal System.Numerics.INumberBase.MinMagnitudeNumber(decimal x, decimal y) { throw null; } static decimal System.Numerics.INumber.MaxNumber(decimal x, decimal y) { throw null; } @@ -2090,6 +2120,7 @@ public DivideByZeroException(string? message, System.Exception? innerException) static double System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static double System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static double System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static double System.Numerics.INumberBase.Zero { get { throw null; } } static double System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static double Abs(double value) { throw null; } @@ -2127,14 +2158,19 @@ public DivideByZeroException(string? message, System.Exception? innerException) public System.TypeCode GetTypeCode() { throw null; } public static double Ieee754Remainder(double left, double right) { throw null; } public static int ILogB(double x) { throw null; } + public static bool IsEvenInteger(double value) { throw null; } public static bool IsFinite(double d) { throw null; } public static bool IsInfinity(double d) { throw null; } + public static bool IsInteger(double value) { throw null; } public static bool IsNaN(double d) { throw null; } public static bool IsNegative(double d) { throw null; } public static bool IsNegativeInfinity(double d) { throw null; } public static bool IsNormal(double d) { throw null; } + public static bool IsOddInteger(double value) { throw null; } + public static bool IsPositive(double value) { throw null; } public static bool IsPositiveInfinity(double d) { throw null; } public static bool IsPow2(double value) { throw null; } + public static bool IsRealNumber(double value) { throw null; } public static bool IsSubnormal(double d) { throw null; } public static double Log(double x) { throw null; } public static double Log(double x, double newBase) { throw null; } @@ -2214,6 +2250,10 @@ public DivideByZeroException(string? message, System.Exception? innerException) static double System.Numerics.IModulusOperators.operator %(double left, double right) { throw null; } static double System.Numerics.IMultiplyOperators.operator checked *(double left, double right) { throw null; } static double System.Numerics.IMultiplyOperators.operator *(double left, double right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(double value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(double value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(double value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(double value) { throw null; } static double System.Numerics.ISubtractionOperators.operator checked -(double left, double right) { throw null; } static double System.Numerics.ISubtractionOperators.operator -(double left, double right) { throw null; } static double System.Numerics.IUnaryNegationOperators.operator checked -(double value) { throw null; } @@ -2694,12 +2734,11 @@ public GopherStyleUriParser() { } public static System.Half One { get { throw null; } } public static System.Half Pi { get { throw null; } } public static System.Half PositiveInfinity { get { throw null; } } - public static System.Half Zero { get { throw null; } } static System.Half System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } - static System.Half System.Numerics.INumberBase.One { get { throw null; } } - static System.Half System.Numerics.INumberBase.Zero { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static System.Half System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static System.Half Tau { get { throw null; } } + public static System.Half Zero { get { throw null; } } public static System.Half Abs(System.Half value) { throw null; } public static System.Half Acos(System.Half x) { throw null; } public static System.Half Acosh(System.Half x) { throw null; } @@ -2734,14 +2773,19 @@ public GopherStyleUriParser() { } public override int GetHashCode() { throw null; } public static System.Half Ieee754Remainder(System.Half left, System.Half right) { throw null; } public static int ILogB(System.Half x) { throw null; } + public static bool IsEvenInteger(System.Half value) { throw null; } public static bool IsFinite(System.Half value) { throw null; } public static bool IsInfinity(System.Half value) { throw null; } + public static bool IsInteger(System.Half value) { throw null; } public static bool IsNaN(System.Half value) { throw null; } public static bool IsNegative(System.Half value) { throw null; } public static bool IsNegativeInfinity(System.Half value) { throw null; } public static bool IsNormal(System.Half value) { throw null; } + public static bool IsOddInteger(System.Half value) { throw null; } + public static bool IsPositive(System.Half value) { throw null; } public static bool IsPositiveInfinity(System.Half value) { throw null; } public static bool IsPow2(System.Half value) { throw null; } + public static bool IsRealNumber(System.Half value) { throw null; } public static bool IsSubnormal(System.Half value) { throw null; } public static System.Half Log(System.Half x) { throw null; } public static System.Half Log(System.Half x, System.Half newBase) { throw null; } @@ -2813,6 +2857,10 @@ public GopherStyleUriParser() { } bool System.Numerics.IFloatingPoint.TryWriteSignificandLittleEndian(System.Span destination, out int bytesWritten) { throw null; } static System.Half System.Numerics.IIncrementOperators.operator checked ++(System.Half value) { throw null; } static System.Half System.Numerics.IMultiplyOperators.operator checked *(System.Half left, System.Half right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(System.Half value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(System.Half value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(System.Half value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(System.Half value) { throw null; } static System.Half System.Numerics.ISubtractionOperators.operator checked -(System.Half left, System.Half right) { throw null; } static System.Half System.Numerics.IUnaryNegationOperators.operator checked -(System.Half value) { throw null; } public static System.Half Tan(System.Half x) { throw null; } @@ -2967,6 +3015,7 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public static System.Int128 One { get { throw null; } } static System.Int128 System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static System.Int128 System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } public static System.Int128 Zero { get { throw null; } } public static System.Int128 Abs(System.Int128 value) { throw null; } public static System.Int128 Clamp(System.Int128 value, System.Int128 min, System.Int128 max) { throw null; } @@ -2980,7 +3029,10 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public bool Equals(System.Int128 other) { throw null; } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } + public static bool IsEvenInteger(System.Int128 value) { throw null; } public static bool IsNegative(System.Int128 value) { throw null; } + public static bool IsOddInteger(System.Int128 value) { throw null; } + public static bool IsPositive(System.Int128 value) { throw null; } public static bool IsPow2(System.Int128 value) { throw null; } public static System.Int128 LeadingZeroCount(System.Int128 value) { throw null; } public static System.Int128 Log2(System.Int128 value) { throw null; } @@ -3094,13 +3146,19 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep int System.Numerics.IBinaryInteger.GetShortestBitLength() { throw null; } bool System.Numerics.IBinaryInteger.TryWriteBigEndian(System.Span destination, out int bytesWritten) { throw null; } bool System.Numerics.IBinaryInteger.TryWriteLittleEndian(System.Span destination, out int bytesWritten) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(System.Int128 value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(System.Int128 value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(System.Int128 value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(System.Int128 value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(System.Int128 value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(System.Int128 value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(System.Int128 value) { throw null; } static System.Int128 System.Numerics.INumberBase.MaxMagnitudeNumber(System.Int128 x, System.Int128 y) { throw null; } static System.Int128 System.Numerics.INumberBase.MinMagnitudeNumber(System.Int128 x, System.Int128 y) { throw null; } static System.Int128 System.Numerics.INumber.MaxNumber(System.Int128 x, System.Int128 y) { throw null; } @@ -3129,6 +3187,7 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static short System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static short System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static short System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static short System.Numerics.INumberBase.Zero { get { throw null; } } static short System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static short Abs(short value) { throw null; } @@ -3144,7 +3203,10 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(short value) { throw null; } public static bool IsNegative(short value) { throw null; } + public static bool IsOddInteger(short value) { throw null; } + public static bool IsPositive(short value) { throw null; } public static bool IsPow2(short value) { throw null; } public static short LeadingZeroCount(short value) { throw null; } public static short Log2(short value) { throw null; } @@ -3202,13 +3264,19 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static short System.Numerics.IModulusOperators.operator %(short left, short right) { throw null; } static short System.Numerics.IMultiplyOperators.operator checked *(short left, short right) { throw null; } static short System.Numerics.IMultiplyOperators.operator *(short left, short right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(short value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(short value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(short value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(short value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(short value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(short value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(short value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(short value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(short value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(short value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(short value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(short value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(short value) { throw null; } static short System.Numerics.INumberBase.MaxMagnitudeNumber(short x, short y) { throw null; } static short System.Numerics.INumberBase.MinMagnitudeNumber(short x, short y) { throw null; } static short System.Numerics.INumber.MaxNumber(short x, short y) { throw null; } @@ -3245,6 +3313,7 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static int System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static int System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static int System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static int System.Numerics.INumberBase.Zero { get { throw null; } } static int System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static int Abs(int value) { throw null; } @@ -3260,7 +3329,10 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(int value) { throw null; } public static bool IsNegative(int value) { throw null; } + public static bool IsOddInteger(int value) { throw null; } + public static bool IsPositive(int value) { throw null; } public static bool IsPow2(int value) { throw null; } public static int LeadingZeroCount(int value) { throw null; } public static int Log2(int value) { throw null; } @@ -3318,13 +3390,19 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static int System.Numerics.IModulusOperators.operator %(int left, int right) { throw null; } static int System.Numerics.IMultiplyOperators.operator checked *(int left, int right) { throw null; } static int System.Numerics.IMultiplyOperators.operator *(int left, int right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(int value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(int value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(int value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(int value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(int value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(int value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(int value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(int value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(int value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(int value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(int value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(int value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(int value) { throw null; } static int System.Numerics.INumberBase.MaxMagnitudeNumber(int x, int y) { throw null; } static int System.Numerics.INumberBase.MinMagnitudeNumber(int x, int y) { throw null; } static int System.Numerics.INumber.MaxNumber(int x, int y) { throw null; } @@ -3361,6 +3439,7 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static long System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static long System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static long System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static long System.Numerics.INumberBase.Zero { get { throw null; } } static long System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static long Abs(long value) { throw null; } @@ -3376,7 +3455,10 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(long value) { throw null; } public static bool IsNegative(long value) { throw null; } + public static bool IsOddInteger(long value) { throw null; } + public static bool IsPositive(long value) { throw null; } public static bool IsPow2(long value) { throw null; } public static long LeadingZeroCount(long value) { throw null; } public static long Log2(long value) { throw null; } @@ -3434,13 +3516,19 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static long System.Numerics.IModulusOperators.operator %(long left, long right) { throw null; } static long System.Numerics.IMultiplyOperators.operator checked *(long left, long right) { throw null; } static long System.Numerics.IMultiplyOperators.operator *(long left, long right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(long value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(long value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(long value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(long value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(long value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(long value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(long value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(long value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(long value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(long value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(long value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(long value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(long value) { throw null; } static long System.Numerics.INumberBase.MaxMagnitudeNumber(long x, long y) { throw null; } static long System.Numerics.INumberBase.MinMagnitudeNumber(long x, long y) { throw null; } static long System.Numerics.INumber.MaxNumber(long x, long y) { throw null; } @@ -3483,6 +3571,7 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static nint System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static nint System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static nint System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static nint System.Numerics.INumberBase.Zero { get { throw null; } } static nint System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static nint Abs(nint value) { throw null; } @@ -3498,7 +3587,10 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public bool Equals(nint other) { throw null; } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } + public static bool IsEvenInteger(nint value) { throw null; } public static bool IsNegative(nint value) { throw null; } + public static bool IsOddInteger(nint value) { throw null; } + public static bool IsPositive(nint value) { throw null; } public static bool IsPow2(nint value) { throw null; } public static nint LeadingZeroCount(nint value) { throw null; } public static nint Log2(nint value) { throw null; } @@ -3552,13 +3644,19 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static nint System.Numerics.IModulusOperators.operator %(nint left, nint right) { throw null; } static nint System.Numerics.IMultiplyOperators.operator checked *(nint left, nint right) { throw null; } static nint System.Numerics.IMultiplyOperators.operator *(nint left, nint right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(nint value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(nint value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(nint value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(nint value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(nint value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(nint value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(nint value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(nint value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(nint value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(nint value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(nint value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(nint value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(nint value) { throw null; } static nint System.Numerics.INumberBase.MaxMagnitudeNumber(nint x, nint y) { throw null; } static nint System.Numerics.INumberBase.MinMagnitudeNumber(nint x, nint y) { throw null; } static nint System.Numerics.INumber.MaxNumber(nint x, nint y) { throw null; } @@ -4405,6 +4503,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S static sbyte System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static sbyte System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static sbyte System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static sbyte System.Numerics.INumberBase.Zero { get { throw null; } } static sbyte System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static sbyte Abs(sbyte value) { throw null; } @@ -4420,7 +4519,10 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public bool Equals(sbyte obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(sbyte value) { throw null; } public static bool IsNegative(sbyte value) { throw null; } + public static bool IsOddInteger(sbyte value) { throw null; } + public static bool IsPositive(sbyte value) { throw null; } public static bool IsPow2(sbyte value) { throw null; } public static sbyte LeadingZeroCount(sbyte value) { throw null; } public static sbyte Log2(sbyte value) { throw null; } @@ -4478,13 +4580,19 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S static sbyte System.Numerics.IModulusOperators.operator %(sbyte left, sbyte right) { throw null; } static sbyte System.Numerics.IMultiplyOperators.operator checked *(sbyte left, sbyte right) { throw null; } static sbyte System.Numerics.IMultiplyOperators.operator *(sbyte left, sbyte right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(sbyte value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(sbyte value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(sbyte value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(sbyte value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(sbyte value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(sbyte value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(sbyte value) { throw null; } static sbyte System.Numerics.INumberBase.MaxMagnitudeNumber(sbyte x, sbyte y) { throw null; } static sbyte System.Numerics.INumberBase.MinMagnitudeNumber(sbyte x, sbyte y) { throw null; } static sbyte System.Numerics.INumber.MaxNumber(sbyte x, sbyte y) { throw null; } @@ -4542,6 +4650,7 @@ public SerializableAttribute() { } static float System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static float System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static float System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static float System.Numerics.INumberBase.Zero { get { throw null; } } static float System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static float Abs(float value) { throw null; } @@ -4579,14 +4688,19 @@ public SerializableAttribute() { } public System.TypeCode GetTypeCode() { throw null; } public static float Ieee754Remainder(float left, float right) { throw null; } public static int ILogB(float x) { throw null; } + public static bool IsEvenInteger(float value) { throw null; } public static bool IsFinite(float f) { throw null; } public static bool IsInfinity(float f) { throw null; } + public static bool IsInteger(float value) { throw null; } public static bool IsNaN(float f) { throw null; } public static bool IsNegative(float f) { throw null; } public static bool IsNegativeInfinity(float f) { throw null; } public static bool IsNormal(float f) { throw null; } + public static bool IsOddInteger(float value) { throw null; } + public static bool IsPositive(float value) { throw null; } public static bool IsPositiveInfinity(float f) { throw null; } public static bool IsPow2(float value) { throw null; } + public static bool IsRealNumber(float value) { throw null; } public static bool IsSubnormal(float f) { throw null; } public static float Log(float x) { throw null; } public static float Log(float x, float newBase) { throw null; } @@ -4666,6 +4780,10 @@ public SerializableAttribute() { } static float System.Numerics.IModulusOperators.operator %(float left, float right) { throw null; } static float System.Numerics.IMultiplyOperators.operator checked *(float left, float right) { throw null; } static float System.Numerics.IMultiplyOperators.operator *(float left, float right) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(float value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(float value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(float value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(float value) { throw null; } static float System.Numerics.ISubtractionOperators.operator checked -(float left, float right) { throw null; } static float System.Numerics.ISubtractionOperators.operator -(float left, float right) { throw null; } static float System.Numerics.IUnaryNegationOperators.operator checked -(float value) { throw null; } @@ -5865,6 +5983,7 @@ public TypeUnloadedException(string? message, System.Exception? innerException) public static System.UInt128 One { get { throw null; } } static System.UInt128 System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static System.UInt128 System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } public static System.UInt128 Zero { get { throw null; } } public static System.UInt128 Clamp(System.UInt128 value, System.UInt128 min, System.UInt128 max) { throw null; } public int CompareTo(object? value) { throw null; } @@ -5876,6 +5995,8 @@ public TypeUnloadedException(string? message, System.Exception? innerException) public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public bool Equals(System.UInt128 other) { throw null; } public override int GetHashCode() { throw null; } + public static bool IsEvenInteger(System.UInt128 value) { throw null; } + public static bool IsOddInteger(System.UInt128 value) { throw null; } public static bool IsPow2(System.UInt128 value) { throw null; } public static System.UInt128 LeadingZeroCount(System.UInt128 value) { throw null; } public static System.UInt128 Log2(System.UInt128 value) { throw null; } @@ -5994,14 +6115,21 @@ public TypeUnloadedException(string? message, System.Exception? innerException) bool System.Numerics.IBinaryInteger.TryWriteBigEndian(System.Span destination, out int bytesWritten) { throw null; } bool System.Numerics.IBinaryInteger.TryWriteLittleEndian(System.Span destination, out int bytesWritten) { throw null; } static System.UInt128 System.Numerics.INumberBase.Abs(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(System.UInt128 value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(System.UInt128 value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(System.UInt128 value) { throw null; } static System.UInt128 System.Numerics.INumberBase.MaxMagnitude(System.UInt128 x, System.UInt128 y) { throw null; } static System.UInt128 System.Numerics.INumberBase.MaxMagnitudeNumber(System.UInt128 x, System.UInt128 y) { throw null; } static System.UInt128 System.Numerics.INumberBase.MinMagnitude(System.UInt128 x, System.UInt128 y) { throw null; } @@ -6034,6 +6162,7 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static ushort System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static ushort System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static ushort System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static ushort System.Numerics.INumberBase.Zero { get { throw null; } } public static ushort Clamp(ushort value, ushort min, ushort max) { throw null; } public int CompareTo(object? value) { throw null; } @@ -6046,6 +6175,8 @@ public TypeUnloadedException(string? message, System.Exception? innerException) public bool Equals(ushort obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(ushort value) { throw null; } + public static bool IsOddInteger(ushort value) { throw null; } public static bool IsPow2(ushort value) { throw null; } public static ushort LeadingZeroCount(ushort value) { throw null; } public static ushort Log2(ushort value) { throw null; } @@ -6102,14 +6233,21 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static ushort System.Numerics.IMultiplyOperators.operator checked *(ushort left, ushort right) { throw null; } static ushort System.Numerics.IMultiplyOperators.operator *(ushort left, ushort right) { throw null; } static ushort System.Numerics.INumberBase.Abs(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(ushort value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(ushort value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(ushort value) { throw null; } static ushort System.Numerics.INumberBase.MaxMagnitude(ushort x, ushort y) { throw null; } static ushort System.Numerics.INumberBase.MaxMagnitudeNumber(ushort x, ushort y) { throw null; } static ushort System.Numerics.INumberBase.MinMagnitude(ushort x, ushort y) { throw null; } @@ -6150,6 +6288,7 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static uint System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static uint System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static uint System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static uint System.Numerics.INumberBase.Zero { get { throw null; } } public static uint Clamp(uint value, uint min, uint max) { throw null; } public int CompareTo(object? value) { throw null; } @@ -6162,6 +6301,8 @@ public TypeUnloadedException(string? message, System.Exception? innerException) public bool Equals(uint obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(uint value) { throw null; } + public static bool IsOddInteger(uint value) { throw null; } public static bool IsPow2(uint value) { throw null; } public static uint LeadingZeroCount(uint value) { throw null; } public static uint Log2(uint value) { throw null; } @@ -6218,14 +6359,21 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static uint System.Numerics.IMultiplyOperators.operator checked *(uint left, uint right) { throw null; } static uint System.Numerics.IMultiplyOperators.operator *(uint left, uint right) { throw null; } static uint System.Numerics.INumberBase.Abs(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(uint value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(uint value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(uint value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(uint value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(uint value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(uint value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(uint value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(uint value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(uint value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(uint value) { throw null; } static uint System.Numerics.INumberBase.MaxMagnitude(uint x, uint y) { throw null; } static uint System.Numerics.INumberBase.MaxMagnitudeNumber(uint x, uint y) { throw null; } static uint System.Numerics.INumberBase.MinMagnitude(uint x, uint y) { throw null; } @@ -6266,6 +6414,7 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static ulong System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static ulong System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static ulong System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static ulong System.Numerics.INumberBase.Zero { get { throw null; } } public static ulong Clamp(ulong value, ulong min, ulong max) { throw null; } public int CompareTo(object? value) { throw null; } @@ -6278,6 +6427,8 @@ public TypeUnloadedException(string? message, System.Exception? innerException) public bool Equals(ulong obj) { throw null; } public override int GetHashCode() { throw null; } public System.TypeCode GetTypeCode() { throw null; } + public static bool IsEvenInteger(ulong value) { throw null; } + public static bool IsOddInteger(ulong value) { throw null; } public static bool IsPow2(ulong value) { throw null; } public static ulong LeadingZeroCount(ulong value) { throw null; } public static ulong Log2(ulong value) { throw null; } @@ -6334,14 +6485,21 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static ulong System.Numerics.IMultiplyOperators.operator checked *(ulong left, ulong right) { throw null; } static ulong System.Numerics.IMultiplyOperators.operator *(ulong left, ulong right) { throw null; } static ulong System.Numerics.INumberBase.Abs(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(ulong value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(ulong value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(ulong value) { throw null; } static ulong System.Numerics.INumberBase.MaxMagnitude(ulong x, ulong y) { throw null; } static ulong System.Numerics.INumberBase.MaxMagnitudeNumber(ulong x, ulong y) { throw null; } static ulong System.Numerics.INumberBase.MinMagnitude(ulong x, ulong y) { throw null; } @@ -6387,6 +6545,7 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static nuint System.Numerics.IMinMaxValue.MinValue { get { throw null; } } static nuint System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static nuint System.Numerics.INumberBase.One { get { throw null; } } + static int System.Numerics.INumberBase.Radix { get { throw null; } } static nuint System.Numerics.INumberBase.Zero { get { throw null; } } public static nuint Add(nuint pointer, int offset) { throw null; } public static nuint Clamp(nuint value, nuint min, nuint max) { throw null; } @@ -6399,6 +6558,8 @@ public TypeUnloadedException(string? message, System.Exception? innerException) public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public bool Equals(nuint other) { throw null; } public override int GetHashCode() { throw null; } + public static bool IsEvenInteger(nuint value) { throw null; } + public static bool IsOddInteger(nuint value) { throw null; } public static bool IsPow2(nuint value) { throw null; } public static nuint LeadingZeroCount(nuint value) { throw null; } public static nuint Log2(nuint value) { throw null; } @@ -6449,14 +6610,21 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static nuint System.Numerics.IMultiplyOperators.operator checked *(nuint left, nuint right) { throw null; } static nuint System.Numerics.IMultiplyOperators.operator *(nuint left, nuint right) { throw null; } static nuint System.Numerics.INumberBase.Abs(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsCanonical(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsComplexNumber(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsFinite(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsImaginaryNumber(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsInfinity(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsInteger(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsNaN(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsNegative(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsNegativeInfinity(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsNormal(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsPositive(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsPositiveInfinity(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsRealNumber(nuint value) { throw null; } static bool System.Numerics.INumberBase.IsSubnormal(nuint value) { throw null; } + static bool System.Numerics.INumberBase.IsZero(nuint value) { throw null; } static nuint System.Numerics.INumberBase.MaxMagnitude(nuint x, nuint y) { throw null; } static nuint System.Numerics.INumberBase.MaxMagnitudeNumber(nuint x, nuint y) { throw null; } static nuint System.Numerics.INumberBase.MinMagnitude(nuint x, nuint y) { throw null; } @@ -10244,19 +10412,29 @@ public partial interface IMultiplyOperators where TSelf public partial interface INumberBase : System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators where TSelf : System.Numerics.INumberBase { static abstract TSelf One { get; } + static abstract int Radix { get; } static abstract TSelf Zero { get; } static abstract TSelf Abs(TSelf value); static abstract TSelf CreateChecked(TOther value) where TOther : INumberBase; static abstract TSelf CreateSaturating(TOther value) where TOther : INumberBase; static abstract TSelf CreateTruncating(TOther value) where TOther : INumberBase; + static abstract bool IsCanonical(TSelf value); + static abstract bool IsComplexNumber(TSelf value); + static abstract bool IsEvenInteger(TSelf value); static abstract bool IsFinite(TSelf value); + static abstract bool IsImaginaryNumber(TSelf value); static abstract bool IsInfinity(TSelf value); + static abstract bool IsInteger(TSelf value); static abstract bool IsNaN(TSelf value); static abstract bool IsNegative(TSelf value); static abstract bool IsNegativeInfinity(TSelf value); static abstract bool IsNormal(TSelf value); + static abstract bool IsOddInteger(TSelf value); + static abstract bool IsPositive(TSelf value); static abstract bool IsPositiveInfinity(TSelf value); + static abstract bool IsRealNumber(TSelf value); static abstract bool IsSubnormal(TSelf value); + static abstract bool IsZero(TSelf value); static abstract TSelf MaxMagnitude(TSelf x, TSelf y); static abstract TSelf MaxMagnitudeNumber(TSelf x, TSelf y); static abstract TSelf MinMagnitude(TSelf x, TSelf y); diff --git a/src/libraries/System.Runtime/tests/System/ByteTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/ByteTests.GenericMath.cs index 98db57107ede1a..2d5262e7145747 100644 --- a/src/libraries/System.Runtime/tests/System/ByteTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/ByteTests.GenericMath.cs @@ -544,6 +544,12 @@ public static void OneTest() Assert.Equal((byte)0x01, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -956,6 +962,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((byte)0x00)); + Assert.True(NumberBaseHelper.IsCanonical((byte)0x01)); + Assert.True(NumberBaseHelper.IsCanonical((byte)0x7F)); + Assert.True(NumberBaseHelper.IsCanonical((byte)0x80)); + Assert.True(NumberBaseHelper.IsCanonical((byte)0xFF)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((byte)0x00)); + Assert.False(NumberBaseHelper.IsComplexNumber((byte)0x01)); + Assert.False(NumberBaseHelper.IsComplexNumber((byte)0x7F)); + Assert.False(NumberBaseHelper.IsComplexNumber((byte)0x80)); + Assert.False(NumberBaseHelper.IsComplexNumber((byte)0xFF)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((byte)0x00)); + Assert.False(NumberBaseHelper.IsEvenInteger((byte)0x01)); + Assert.False(NumberBaseHelper.IsEvenInteger((byte)0x7F)); + Assert.True(NumberBaseHelper.IsEvenInteger((byte)0x80)); + Assert.False(NumberBaseHelper.IsEvenInteger((byte)0xFF)); + } + [Fact] public static void IsFiniteTest() { @@ -966,6 +1002,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite((byte)0xFF)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((byte)0x00)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((byte)0x01)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((byte)0x7F)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((byte)0x80)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((byte)0xFF)); + } + [Fact] public static void IsInfinityTest() { @@ -976,6 +1022,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity((byte)0xFF)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((byte)0x00)); + Assert.True(NumberBaseHelper.IsInteger((byte)0x01)); + Assert.True(NumberBaseHelper.IsInteger((byte)0x7F)); + Assert.True(NumberBaseHelper.IsInteger((byte)0x80)); + Assert.True(NumberBaseHelper.IsInteger((byte)0xFF)); + } + [Fact] public static void IsNaNTest() { @@ -1016,6 +1072,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal((byte)0xFF)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((byte)0x00)); + Assert.True(NumberBaseHelper.IsOddInteger((byte)0x01)); + Assert.True(NumberBaseHelper.IsOddInteger((byte)0x7F)); + Assert.False(NumberBaseHelper.IsOddInteger((byte)0x80)); + Assert.True(NumberBaseHelper.IsOddInteger((byte)0xFF)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((byte)0x00)); + Assert.True(NumberBaseHelper.IsPositive((byte)0x01)); + Assert.True(NumberBaseHelper.IsPositive((byte)0x7F)); + Assert.True(NumberBaseHelper.IsPositive((byte)0x80)); + Assert.True(NumberBaseHelper.IsPositive((byte)0xFF)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1026,6 +1102,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity((byte)0xFF)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((byte)0x00)); + Assert.True(NumberBaseHelper.IsRealNumber((byte)0x01)); + Assert.True(NumberBaseHelper.IsRealNumber((byte)0x7F)); + Assert.True(NumberBaseHelper.IsRealNumber((byte)0x80)); + Assert.True(NumberBaseHelper.IsRealNumber((byte)0xFF)); + } + [Fact] public static void IsSubnormalTest() { @@ -1036,6 +1122,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal((byte)0xFF)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((byte)0x00)); + Assert.False(NumberBaseHelper.IsZero((byte)0x01)); + Assert.False(NumberBaseHelper.IsZero((byte)0x7F)); + Assert.False(NumberBaseHelper.IsZero((byte)0x80)); + Assert.False(NumberBaseHelper.IsZero((byte)0xFF)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/CharTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/CharTests.GenericMath.cs index 88eb8701fbe65c..f471e17249f992 100644 --- a/src/libraries/System.Runtime/tests/System/CharTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/CharTests.GenericMath.cs @@ -543,6 +543,12 @@ public static void OneTest() Assert.Equal((char)0x0001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -955,6 +961,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((char)0x0000)); + Assert.True(NumberBaseHelper.IsCanonical((char)0x0001)); + Assert.True(NumberBaseHelper.IsCanonical((char)0x7FFF)); + Assert.True(NumberBaseHelper.IsCanonical((char)0x8000)); + Assert.True(NumberBaseHelper.IsCanonical((char)0xFFFF)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((char)0x0000)); + Assert.False(NumberBaseHelper.IsComplexNumber((char)0x0001)); + Assert.False(NumberBaseHelper.IsComplexNumber((char)0x7FFF)); + Assert.False(NumberBaseHelper.IsComplexNumber((char)0x8000)); + Assert.False(NumberBaseHelper.IsComplexNumber((char)0xFFFF)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((char)0x0000)); + Assert.False(NumberBaseHelper.IsEvenInteger((char)0x0001)); + Assert.False(NumberBaseHelper.IsEvenInteger((char)0x7FFF)); + Assert.True(NumberBaseHelper.IsEvenInteger((char)0x8000)); + Assert.False(NumberBaseHelper.IsEvenInteger((char)0xFFFF)); + } + [Fact] public static void IsFiniteTest() { @@ -965,6 +1001,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite((char)0xFFFF)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((char)0x0000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((char)0x0001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((char)0x7FFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((char)0x8000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((char)0xFFFF)); + } + [Fact] public static void IsInfinityTest() { @@ -975,6 +1021,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity((char)0xFFFF)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((char)0x0000)); + Assert.True(NumberBaseHelper.IsInteger((char)0x0001)); + Assert.True(NumberBaseHelper.IsInteger((char)0x7FFF)); + Assert.True(NumberBaseHelper.IsInteger((char)0x8000)); + Assert.True(NumberBaseHelper.IsInteger((char)0xFFFF)); + } + [Fact] public static void IsNaNTest() { @@ -1015,6 +1071,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal((char)0xFFFF)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((char)0x0000)); + Assert.True(NumberBaseHelper.IsOddInteger((char)0x0001)); + Assert.True(NumberBaseHelper.IsOddInteger((char)0x7FFF)); + Assert.False(NumberBaseHelper.IsOddInteger((char)0x8000)); + Assert.True(NumberBaseHelper.IsOddInteger((char)0xFFFF)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((char)0x0000)); + Assert.True(NumberBaseHelper.IsPositive((char)0x0001)); + Assert.True(NumberBaseHelper.IsPositive((char)0x7FFF)); + Assert.True(NumberBaseHelper.IsPositive((char)0x8000)); + Assert.True(NumberBaseHelper.IsPositive((char)0xFFFF)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1025,6 +1101,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity((char)0xFFFF)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((char)0x0000)); + Assert.True(NumberBaseHelper.IsRealNumber((char)0x0001)); + Assert.True(NumberBaseHelper.IsRealNumber((char)0x7FFF)); + Assert.True(NumberBaseHelper.IsRealNumber((char)0x8000)); + Assert.True(NumberBaseHelper.IsRealNumber((char)0xFFFF)); + } + [Fact] public static void IsSubnormalTest() { @@ -1035,6 +1121,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal((char)0xFFFF)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((char)0x0000)); + Assert.False(NumberBaseHelper.IsZero((char)0x0001)); + Assert.False(NumberBaseHelper.IsZero((char)0x7FFF)); + Assert.False(NumberBaseHelper.IsZero((char)0x8000)); + Assert.False(NumberBaseHelper.IsZero((char)0xFFFF)); + } + [Fact] public static void MinMagnitudeMagnitude() { diff --git a/src/libraries/System.Runtime/tests/System/DecimalTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/DecimalTests.GenericMath.cs index 5a820c92c415df..f49ce0c7c94e42 100644 --- a/src/libraries/System.Runtime/tests/System/DecimalTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/DecimalTests.GenericMath.cs @@ -541,6 +541,12 @@ public static void OneTest() Assert.Equal(1.0m, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(10, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1024,6 +1030,83 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(decimal.MinValue)); + Assert.False(NumberBaseHelper.IsCanonical(-1.0m)); + Assert.False(NumberBaseHelper.IsCanonical(-0.0m)); + Assert.False(NumberBaseHelper.IsCanonical(0.0m)); + Assert.False(NumberBaseHelper.IsCanonical(1.0m)); + Assert.True(NumberBaseHelper.IsCanonical(decimal.MaxValue)); + + Assert.True(NumberBaseHelper.IsCanonical(-10m)); + Assert.True(NumberBaseHelper.IsCanonical(-1.2m)); + Assert.True(NumberBaseHelper.IsCanonical(-1m)); + Assert.True(NumberBaseHelper.IsCanonical(-0.1m)); + Assert.True(NumberBaseHelper.IsCanonical(-0m)); + Assert.True(NumberBaseHelper.IsCanonical(0m)); + Assert.True(NumberBaseHelper.IsCanonical(0.1m)); + Assert.True(NumberBaseHelper.IsCanonical(1m)); + Assert.True(NumberBaseHelper.IsCanonical(1.2m)); + Assert.True(NumberBaseHelper.IsCanonical(10m)); + + Assert.False(NumberBaseHelper.IsCanonical(-10.0m)); + Assert.False(NumberBaseHelper.IsCanonical(-1.20m)); + Assert.False(NumberBaseHelper.IsCanonical(-0.10m)); + Assert.False(NumberBaseHelper.IsCanonical(0.10m)); + Assert.False(NumberBaseHelper.IsCanonical(1.20m)); + Assert.False(NumberBaseHelper.IsCanonical(10.0m)); + + Assert.False(NumberBaseHelper.IsCanonical(0.0000000000000000000000000000m)); + Assert.False(NumberBaseHelper.IsCanonical(1.0000000000000000000000000000m)); + Assert.False(NumberBaseHelper.IsCanonical(10.000000000000000000000000000m)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(decimal.MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(-1.0m)); + Assert.False(NumberBaseHelper.IsComplexNumber(-0.0m)); + Assert.False(NumberBaseHelper.IsComplexNumber(0.0m)); + Assert.False(NumberBaseHelper.IsComplexNumber(1.0m)); + Assert.False(NumberBaseHelper.IsComplexNumber(decimal.MaxValue)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.False(NumberBaseHelper.IsEvenInteger(decimal.MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1.0m)); + Assert.True(NumberBaseHelper.IsEvenInteger(-0.0m)); + Assert.True(NumberBaseHelper.IsEvenInteger(0.0m)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.0m)); + Assert.False(NumberBaseHelper.IsEvenInteger(decimal.MaxValue)); + + Assert.True(NumberBaseHelper.IsEvenInteger(-10m)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1.2m)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1m)); + Assert.False(NumberBaseHelper.IsEvenInteger(-0.1m)); + Assert.True(NumberBaseHelper.IsEvenInteger(-0m)); + Assert.True(NumberBaseHelper.IsEvenInteger(0m)); + Assert.False(NumberBaseHelper.IsEvenInteger(0.1m)); + Assert.False(NumberBaseHelper.IsEvenInteger(1m)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.2m)); + Assert.True(NumberBaseHelper.IsEvenInteger(10m)); + + Assert.True(NumberBaseHelper.IsEvenInteger(-10.0m)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1.20m)); + Assert.False(NumberBaseHelper.IsEvenInteger(-0.10m)); + Assert.False(NumberBaseHelper.IsEvenInteger(0.10m)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.20m)); + Assert.True(NumberBaseHelper.IsEvenInteger(10.0m)); + + Assert.True(NumberBaseHelper.IsEvenInteger(0.0000000000000000000000000000m)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.0000000000000000000000000000m)); + Assert.True(NumberBaseHelper.IsEvenInteger(10.000000000000000000000000000m)); + } + [Fact] public static void IsFiniteTest() { @@ -1035,6 +1118,17 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(decimal.MaxValue)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(decimal.MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-1.0m)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-0.0m)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(0.0m)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(1.0m)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(decimal.MaxValue)); + } + [Fact] public static void IsInfinityTest() { @@ -1046,6 +1140,39 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(decimal.MaxValue)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger(decimal.MinValue)); + Assert.True(NumberBaseHelper.IsInteger(-1.0m)); + Assert.True(NumberBaseHelper.IsInteger(-0.0m)); + Assert.True(NumberBaseHelper.IsInteger(0.0m)); + Assert.True(NumberBaseHelper.IsInteger(1.0m)); + Assert.True(NumberBaseHelper.IsInteger(decimal.MaxValue)); + + Assert.True(NumberBaseHelper.IsInteger(-10m)); + Assert.False(NumberBaseHelper.IsInteger(-1.2m)); + Assert.True(NumberBaseHelper.IsInteger(-1m)); + Assert.False(NumberBaseHelper.IsInteger(-0.1m)); + Assert.True(NumberBaseHelper.IsInteger(-0m)); + Assert.True(NumberBaseHelper.IsInteger(0m)); + Assert.False(NumberBaseHelper.IsInteger(0.1m)); + Assert.True(NumberBaseHelper.IsInteger(1m)); + Assert.False(NumberBaseHelper.IsInteger(1.2m)); + Assert.True(NumberBaseHelper.IsInteger(10m)); + + Assert.True(NumberBaseHelper.IsInteger(-10.0m)); + Assert.False(NumberBaseHelper.IsInteger(-1.20m)); + Assert.False(NumberBaseHelper.IsInteger(-0.10m)); + Assert.False(NumberBaseHelper.IsInteger(0.10m)); + Assert.False(NumberBaseHelper.IsInteger(1.20m)); + Assert.True(NumberBaseHelper.IsInteger(10.0m)); + + Assert.True(NumberBaseHelper.IsInteger(0.0000000000000000000000000000m)); + Assert.True(NumberBaseHelper.IsInteger(1.0000000000000000000000000000m)); + Assert.True(NumberBaseHelper.IsInteger(10.000000000000000000000000000m)); + } + [Fact] public static void IsNaNTest() { @@ -1090,6 +1217,50 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(decimal.MaxValue)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.True(NumberBaseHelper.IsOddInteger(decimal.MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(-1.0m)); + Assert.False(NumberBaseHelper.IsOddInteger(-0.0m)); + Assert.False(NumberBaseHelper.IsOddInteger(0.0m)); + Assert.True(NumberBaseHelper.IsOddInteger(1.0m)); + Assert.True(NumberBaseHelper.IsOddInteger(decimal.MaxValue)); + + Assert.False(NumberBaseHelper.IsOddInteger(-10m)); + Assert.False(NumberBaseHelper.IsOddInteger(-1.2m)); + Assert.True(NumberBaseHelper.IsOddInteger(-1m)); + Assert.False(NumberBaseHelper.IsOddInteger(-0.1m)); + Assert.False(NumberBaseHelper.IsOddInteger(-0m)); + Assert.False(NumberBaseHelper.IsOddInteger(0m)); + Assert.False(NumberBaseHelper.IsOddInteger(0.1m)); + Assert.True(NumberBaseHelper.IsOddInteger(1m)); + Assert.False(NumberBaseHelper.IsOddInteger(1.2m)); + Assert.False(NumberBaseHelper.IsOddInteger(10m)); + + Assert.False(NumberBaseHelper.IsOddInteger(-10.0m)); + Assert.False(NumberBaseHelper.IsOddInteger(-1.20m)); + Assert.False(NumberBaseHelper.IsOddInteger(-0.10m)); + Assert.False(NumberBaseHelper.IsOddInteger(0.10m)); + Assert.False(NumberBaseHelper.IsOddInteger(1.20m)); + Assert.False(NumberBaseHelper.IsOddInteger(10.0m)); + + Assert.False(NumberBaseHelper.IsOddInteger(0.0000000000000000000000000000m)); + Assert.True(NumberBaseHelper.IsOddInteger(1.0000000000000000000000000000m)); + Assert.False(NumberBaseHelper.IsOddInteger(10.000000000000000000000000000m)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.False(NumberBaseHelper.IsPositive(decimal.MinValue)); + Assert.False(NumberBaseHelper.IsPositive(-1.0m)); + Assert.False(NumberBaseHelper.IsPositive(-0.0m)); + Assert.True(NumberBaseHelper.IsPositive(0.0m)); + Assert.True(NumberBaseHelper.IsPositive(1.0m)); + Assert.True(NumberBaseHelper.IsPositive(decimal.MaxValue)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1101,6 +1272,17 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(decimal.MaxValue)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(decimal.MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(-1.0m)); + Assert.True(NumberBaseHelper.IsRealNumber(-0.0m)); + Assert.True(NumberBaseHelper.IsRealNumber(0.0m)); + Assert.True(NumberBaseHelper.IsRealNumber(1.0m)); + Assert.True(NumberBaseHelper.IsRealNumber(decimal.MaxValue)); + } + [Fact] public static void IsSubnormalTest() { @@ -1112,6 +1294,39 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(decimal.MaxValue)); } + [Fact] + public static void IsZeroTest() + { + Assert.False(NumberBaseHelper.IsZero(decimal.MinValue)); + Assert.False(NumberBaseHelper.IsZero(-1.0m)); + Assert.True(NumberBaseHelper.IsZero(-0.0m)); + Assert.True(NumberBaseHelper.IsZero(0.0m)); + Assert.False(NumberBaseHelper.IsZero(1.0m)); + Assert.False(NumberBaseHelper.IsZero(decimal.MaxValue)); + + Assert.False(NumberBaseHelper.IsZero(-10m)); + Assert.False(NumberBaseHelper.IsZero(-1.2m)); + Assert.False(NumberBaseHelper.IsZero(-1m)); + Assert.False(NumberBaseHelper.IsZero(-0.1m)); + Assert.True(NumberBaseHelper.IsZero(-0m)); + Assert.True(NumberBaseHelper.IsZero(0m)); + Assert.False(NumberBaseHelper.IsZero(0.1m)); + Assert.False(NumberBaseHelper.IsZero(1m)); + Assert.False(NumberBaseHelper.IsZero(1.2m)); + Assert.False(NumberBaseHelper.IsZero(10m)); + + Assert.False(NumberBaseHelper.IsZero(-10.0m)); + Assert.False(NumberBaseHelper.IsZero(-1.20m)); + Assert.False(NumberBaseHelper.IsZero(-0.10m)); + Assert.False(NumberBaseHelper.IsZero(0.10m)); + Assert.False(NumberBaseHelper.IsZero(1.20m)); + Assert.False(NumberBaseHelper.IsZero(10.0m)); + + Assert.True(NumberBaseHelper.IsZero(0.0000000000000000000000000000m)); + Assert.False(NumberBaseHelper.IsZero(1.0000000000000000000000000000m)); + Assert.False(NumberBaseHelper.IsZero(10.000000000000000000000000000m)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/DoubleTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/DoubleTests.GenericMath.cs index 1b193ffa2b4808..f0868228a67aa8 100644 --- a/src/libraries/System.Runtime/tests/System/DoubleTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/DoubleTests.GenericMath.cs @@ -987,6 +987,12 @@ public static void OneTest() AssertBitwiseEqual(1.0, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1481,62 +1487,162 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsCanonical(double.MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(-1.0)); + Assert.True(NumberBaseHelper.IsCanonical(-MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(-0.0)); + Assert.True(NumberBaseHelper.IsCanonical(double.NaN)); + Assert.True(NumberBaseHelper.IsCanonical(0.0)); + Assert.True(NumberBaseHelper.IsCanonical(double.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(1.0)); + Assert.True(NumberBaseHelper.IsCanonical(double.MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(double.PositiveInfinity)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(-1.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(-0.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.NaN)); + Assert.False(NumberBaseHelper.IsComplexNumber(0.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(1.0)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(double.PositiveInfinity)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.False(NumberBaseHelper.IsEvenInteger(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsEvenInteger(double.MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1.0)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsEvenInteger(-0.0)); + Assert.False(NumberBaseHelper.IsEvenInteger(double.NaN)); + Assert.True(NumberBaseHelper.IsEvenInteger(0.0)); + Assert.False(NumberBaseHelper.IsEvenInteger(double.Epsilon)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.0)); + Assert.True(NumberBaseHelper.IsEvenInteger(double.MaxValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(double.PositiveInfinity)); + } + [Fact] public static void IsFiniteTest() { Assert.False(NumberBaseHelper.IsFinite(double.NegativeInfinity)); Assert.True(NumberBaseHelper.IsFinite(double.MinValue)); - Assert.True(NumberBaseHelper.IsFinite(-1.0f)); + Assert.True(NumberBaseHelper.IsFinite(-1.0)); Assert.True(NumberBaseHelper.IsFinite(-MinNormal)); Assert.True(NumberBaseHelper.IsFinite(-MaxSubnormal)); Assert.True(NumberBaseHelper.IsFinite(-double.Epsilon)); - Assert.True(NumberBaseHelper.IsFinite(-0.0f)); + Assert.True(NumberBaseHelper.IsFinite(-0.0)); Assert.False(NumberBaseHelper.IsFinite(double.NaN)); - Assert.True(NumberBaseHelper.IsFinite(0.0f)); + Assert.True(NumberBaseHelper.IsFinite(0.0)); Assert.True(NumberBaseHelper.IsFinite(double.Epsilon)); Assert.True(NumberBaseHelper.IsFinite(MaxSubnormal)); Assert.True(NumberBaseHelper.IsFinite(MinNormal)); - Assert.True(NumberBaseHelper.IsFinite(1.0f)); + Assert.True(NumberBaseHelper.IsFinite(1.0)); Assert.True(NumberBaseHelper.IsFinite(double.MaxValue)); Assert.False(NumberBaseHelper.IsFinite(double.PositiveInfinity)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-1.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-0.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.NaN)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(0.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(1.0)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(double.PositiveInfinity)); + } + [Fact] public static void IsInfinityTest() { Assert.True(NumberBaseHelper.IsInfinity(double.NegativeInfinity)); Assert.False(NumberBaseHelper.IsInfinity(double.MinValue)); - Assert.False(NumberBaseHelper.IsInfinity(-1.0f)); + Assert.False(NumberBaseHelper.IsInfinity(-1.0)); Assert.False(NumberBaseHelper.IsInfinity(-MinNormal)); Assert.False(NumberBaseHelper.IsInfinity(-MaxSubnormal)); Assert.False(NumberBaseHelper.IsInfinity(-double.Epsilon)); - Assert.False(NumberBaseHelper.IsInfinity(-0.0f)); + Assert.False(NumberBaseHelper.IsInfinity(-0.0)); Assert.False(NumberBaseHelper.IsInfinity(double.NaN)); - Assert.False(NumberBaseHelper.IsInfinity(0.0f)); + Assert.False(NumberBaseHelper.IsInfinity(0.0)); Assert.False(NumberBaseHelper.IsInfinity(double.Epsilon)); Assert.False(NumberBaseHelper.IsInfinity(MaxSubnormal)); Assert.False(NumberBaseHelper.IsInfinity(MinNormal)); - Assert.False(NumberBaseHelper.IsInfinity(1.0f)); + Assert.False(NumberBaseHelper.IsInfinity(1.0)); Assert.False(NumberBaseHelper.IsInfinity(double.MaxValue)); Assert.True(NumberBaseHelper.IsInfinity(double.PositiveInfinity)); } + [Fact] + public static void IsIntegerTest() + { + Assert.False(NumberBaseHelper.IsInteger(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsInteger(double.MinValue)); + Assert.True(NumberBaseHelper.IsInteger(-1.0)); + Assert.False(NumberBaseHelper.IsInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsInteger(-0.0)); + Assert.False(NumberBaseHelper.IsInteger(double.NaN)); + Assert.True(NumberBaseHelper.IsInteger(0.0)); + Assert.False(NumberBaseHelper.IsInteger(double.Epsilon)); + Assert.False(NumberBaseHelper.IsInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsInteger(1.0)); + Assert.True(NumberBaseHelper.IsInteger(double.MaxValue)); + Assert.False(NumberBaseHelper.IsInteger(double.PositiveInfinity)); + } + [Fact] public static void IsNaNTest() { Assert.False(NumberBaseHelper.IsNaN(double.NegativeInfinity)); Assert.False(NumberBaseHelper.IsNaN(double.MinValue)); - Assert.False(NumberBaseHelper.IsNaN(-1.0f)); + Assert.False(NumberBaseHelper.IsNaN(-1.0)); Assert.False(NumberBaseHelper.IsNaN(-MinNormal)); Assert.False(NumberBaseHelper.IsNaN(-MaxSubnormal)); Assert.False(NumberBaseHelper.IsNaN(-double.Epsilon)); - Assert.False(NumberBaseHelper.IsNaN(-0.0f)); + Assert.False(NumberBaseHelper.IsNaN(-0.0)); Assert.True(NumberBaseHelper.IsNaN(double.NaN)); - Assert.False(NumberBaseHelper.IsNaN(0.0f)); + Assert.False(NumberBaseHelper.IsNaN(0.0)); Assert.False(NumberBaseHelper.IsNaN(double.Epsilon)); Assert.False(NumberBaseHelper.IsNaN(MaxSubnormal)); Assert.False(NumberBaseHelper.IsNaN(MinNormal)); - Assert.False(NumberBaseHelper.IsNaN(1.0f)); + Assert.False(NumberBaseHelper.IsNaN(1.0)); Assert.False(NumberBaseHelper.IsNaN(double.MaxValue)); Assert.False(NumberBaseHelper.IsNaN(double.PositiveInfinity)); } @@ -1546,17 +1652,17 @@ public static void IsNegativeTest() { Assert.True(NumberBaseHelper.IsNegative(double.NegativeInfinity)); Assert.True(NumberBaseHelper.IsNegative(double.MinValue)); - Assert.True(NumberBaseHelper.IsNegative(-1.0f)); + Assert.True(NumberBaseHelper.IsNegative(-1.0)); Assert.True(NumberBaseHelper.IsNegative(-MinNormal)); Assert.True(NumberBaseHelper.IsNegative(-MaxSubnormal)); Assert.True(NumberBaseHelper.IsNegative(-double.Epsilon)); - Assert.True(NumberBaseHelper.IsNegative(-0.0f)); + Assert.True(NumberBaseHelper.IsNegative(-0.0)); Assert.True(NumberBaseHelper.IsNegative(double.NaN)); - Assert.False(NumberBaseHelper.IsNegative(0.0f)); + Assert.False(NumberBaseHelper.IsNegative(0.0)); Assert.False(NumberBaseHelper.IsNegative(double.Epsilon)); Assert.False(NumberBaseHelper.IsNegative(MaxSubnormal)); Assert.False(NumberBaseHelper.IsNegative(MinNormal)); - Assert.False(NumberBaseHelper.IsNegative(1.0f)); + Assert.False(NumberBaseHelper.IsNegative(1.0)); Assert.False(NumberBaseHelper.IsNegative(double.MaxValue)); Assert.False(NumberBaseHelper.IsNegative(double.PositiveInfinity)); } @@ -1566,17 +1672,17 @@ public static void IsNegativeInfinityTest() { Assert.True(NumberBaseHelper.IsNegativeInfinity(double.NegativeInfinity)); Assert.False(NumberBaseHelper.IsNegativeInfinity(double.MinValue)); - Assert.False(NumberBaseHelper.IsNegativeInfinity(-1.0f)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(-1.0)); Assert.False(NumberBaseHelper.IsNegativeInfinity(-MinNormal)); Assert.False(NumberBaseHelper.IsNegativeInfinity(-MaxSubnormal)); Assert.False(NumberBaseHelper.IsNegativeInfinity(-double.Epsilon)); - Assert.False(NumberBaseHelper.IsNegativeInfinity(-0.0f)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(-0.0)); Assert.False(NumberBaseHelper.IsNegativeInfinity(double.NaN)); - Assert.False(NumberBaseHelper.IsNegativeInfinity(0.0f)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(0.0)); Assert.False(NumberBaseHelper.IsNegativeInfinity(double.Epsilon)); Assert.False(NumberBaseHelper.IsNegativeInfinity(MaxSubnormal)); Assert.False(NumberBaseHelper.IsNegativeInfinity(MinNormal)); - Assert.False(NumberBaseHelper.IsNegativeInfinity(1.0f)); + Assert.False(NumberBaseHelper.IsNegativeInfinity(1.0)); Assert.False(NumberBaseHelper.IsNegativeInfinity(double.MaxValue)); Assert.False(NumberBaseHelper.IsNegativeInfinity(double.PositiveInfinity)); } @@ -1586,61 +1692,141 @@ public static void IsNormalTest() { Assert.False(NumberBaseHelper.IsNormal(double.NegativeInfinity)); Assert.True(NumberBaseHelper.IsNormal(double.MinValue)); - Assert.True(NumberBaseHelper.IsNormal(-1.0f)); + Assert.True(NumberBaseHelper.IsNormal(-1.0)); Assert.True(NumberBaseHelper.IsNormal(-MinNormal)); Assert.False(NumberBaseHelper.IsNormal(-MaxSubnormal)); Assert.False(NumberBaseHelper.IsNormal(-double.Epsilon)); - Assert.False(NumberBaseHelper.IsNormal(-0.0f)); + Assert.False(NumberBaseHelper.IsNormal(-0.0)); Assert.False(NumberBaseHelper.IsNormal(double.NaN)); - Assert.False(NumberBaseHelper.IsNormal(0.0f)); + Assert.False(NumberBaseHelper.IsNormal(0.0)); Assert.False(NumberBaseHelper.IsNormal(double.Epsilon)); Assert.False(NumberBaseHelper.IsNormal(MaxSubnormal)); Assert.True(NumberBaseHelper.IsNormal(MinNormal)); - Assert.True(NumberBaseHelper.IsNormal(1.0f)); + Assert.True(NumberBaseHelper.IsNormal(1.0)); Assert.True(NumberBaseHelper.IsNormal(double.MaxValue)); Assert.False(NumberBaseHelper.IsNormal(double.PositiveInfinity)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsOddInteger(double.MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(-1.0)); + Assert.False(NumberBaseHelper.IsOddInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(-0.0)); + Assert.False(NumberBaseHelper.IsOddInteger(double.NaN)); + Assert.False(NumberBaseHelper.IsOddInteger(0.0)); + Assert.False(NumberBaseHelper.IsOddInteger(double.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsOddInteger(1.0)); + Assert.False(NumberBaseHelper.IsOddInteger(double.MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(double.PositiveInfinity)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.False(NumberBaseHelper.IsPositive(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsPositive(double.MinValue)); + Assert.False(NumberBaseHelper.IsPositive(-1.0)); + Assert.False(NumberBaseHelper.IsPositive(-MinNormal)); + Assert.False(NumberBaseHelper.IsPositive(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositive(-double.Epsilon)); + Assert.False(NumberBaseHelper.IsPositive(-0.0)); + Assert.False(NumberBaseHelper.IsPositive(double.NaN)); + Assert.True(NumberBaseHelper.IsPositive(0.0)); + Assert.True(NumberBaseHelper.IsPositive(double.Epsilon)); + Assert.True(NumberBaseHelper.IsPositive(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsPositive(MinNormal)); + Assert.True(NumberBaseHelper.IsPositive(1.0)); + Assert.True(NumberBaseHelper.IsPositive(double.MaxValue)); + Assert.True(NumberBaseHelper.IsPositive(double.PositiveInfinity)); + } + [Fact] public static void IsPositiveInfinityTest() { Assert.False(NumberBaseHelper.IsPositiveInfinity(double.NegativeInfinity)); Assert.False(NumberBaseHelper.IsPositiveInfinity(double.MinValue)); - Assert.False(NumberBaseHelper.IsPositiveInfinity(-1.0f)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(-1.0)); Assert.False(NumberBaseHelper.IsPositiveInfinity(-MinNormal)); Assert.False(NumberBaseHelper.IsPositiveInfinity(-MaxSubnormal)); Assert.False(NumberBaseHelper.IsPositiveInfinity(-double.Epsilon)); - Assert.False(NumberBaseHelper.IsPositiveInfinity(-0.0f)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(-0.0)); Assert.False(NumberBaseHelper.IsPositiveInfinity(double.NaN)); - Assert.False(NumberBaseHelper.IsPositiveInfinity(0.0f)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(0.0)); Assert.False(NumberBaseHelper.IsPositiveInfinity(double.Epsilon)); Assert.False(NumberBaseHelper.IsPositiveInfinity(MaxSubnormal)); Assert.False(NumberBaseHelper.IsPositiveInfinity(MinNormal)); - Assert.False(NumberBaseHelper.IsPositiveInfinity(1.0f)); + Assert.False(NumberBaseHelper.IsPositiveInfinity(1.0)); Assert.False(NumberBaseHelper.IsPositiveInfinity(double.MaxValue)); Assert.True(NumberBaseHelper.IsPositiveInfinity(double.PositiveInfinity)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(double.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsRealNumber(double.MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(-1.0)); + Assert.True(NumberBaseHelper.IsRealNumber(-MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(-0.0)); + Assert.False(NumberBaseHelper.IsRealNumber(double.NaN)); + Assert.True(NumberBaseHelper.IsRealNumber(0.0)); + Assert.True(NumberBaseHelper.IsRealNumber(double.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(1.0)); + Assert.True(NumberBaseHelper.IsRealNumber(double.MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(double.PositiveInfinity)); + } + [Fact] public static void IsSubnormalTest() { Assert.False(NumberBaseHelper.IsSubnormal(double.NegativeInfinity)); Assert.False(NumberBaseHelper.IsSubnormal(double.MinValue)); - Assert.False(NumberBaseHelper.IsSubnormal(-1.0f)); + Assert.False(NumberBaseHelper.IsSubnormal(-1.0)); Assert.False(NumberBaseHelper.IsSubnormal(-MinNormal)); Assert.True(NumberBaseHelper.IsSubnormal(-MaxSubnormal)); Assert.True(NumberBaseHelper.IsSubnormal(-double.Epsilon)); - Assert.False(NumberBaseHelper.IsSubnormal(-0.0f)); + Assert.False(NumberBaseHelper.IsSubnormal(-0.0)); Assert.False(NumberBaseHelper.IsSubnormal(double.NaN)); - Assert.False(NumberBaseHelper.IsSubnormal(0.0f)); + Assert.False(NumberBaseHelper.IsSubnormal(0.0)); Assert.True(NumberBaseHelper.IsSubnormal(double.Epsilon)); Assert.True(NumberBaseHelper.IsSubnormal(MaxSubnormal)); Assert.False(NumberBaseHelper.IsSubnormal(MinNormal)); - Assert.False(NumberBaseHelper.IsSubnormal(1.0f)); + Assert.False(NumberBaseHelper.IsSubnormal(1.0)); Assert.False(NumberBaseHelper.IsSubnormal(double.MaxValue)); Assert.False(NumberBaseHelper.IsSubnormal(double.PositiveInfinity)); } + [Fact] + public static void IsZeroTest() + { + Assert.False(NumberBaseHelper.IsZero(double.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsZero(double.MinValue)); + Assert.False(NumberBaseHelper.IsZero(-1.0)); + Assert.False(NumberBaseHelper.IsZero(-MinNormal)); + Assert.False(NumberBaseHelper.IsZero(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(-double.Epsilon)); + Assert.True(NumberBaseHelper.IsZero(-0.0)); + Assert.False(NumberBaseHelper.IsZero(double.NaN)); + Assert.True(NumberBaseHelper.IsZero(0.0)); + Assert.False(NumberBaseHelper.IsZero(double.Epsilon)); + Assert.False(NumberBaseHelper.IsZero(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(MinNormal)); + Assert.False(NumberBaseHelper.IsZero(1.0)); + Assert.False(NumberBaseHelper.IsZero(double.MaxValue)); + Assert.False(NumberBaseHelper.IsZero(double.PositiveInfinity)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/HalfTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/HalfTests.GenericMath.cs index bf2418d3275d2a..c3d521808c32e4 100644 --- a/src/libraries/System.Runtime/tests/System/HalfTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/HalfTests.GenericMath.cs @@ -1005,6 +1005,12 @@ public static void OneTest() AssertBitwiseEqual(One, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1499,6 +1505,66 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(Half.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsCanonical(Half.MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(NegativeOne)); + Assert.True(NumberBaseHelper.IsCanonical(-MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(-Half.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(NegativeZero)); + Assert.True(NumberBaseHelper.IsCanonical(Half.NaN)); + Assert.True(NumberBaseHelper.IsCanonical(Zero)); + Assert.True(NumberBaseHelper.IsCanonical(Half.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(One)); + Assert.True(NumberBaseHelper.IsCanonical(Half.MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(Half.PositiveInfinity)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(Half.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsComplexNumber(Half.MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(NegativeOne)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-Half.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(NegativeZero)); + Assert.False(NumberBaseHelper.IsComplexNumber(Half.NaN)); + Assert.False(NumberBaseHelper.IsComplexNumber(Zero)); + Assert.False(NumberBaseHelper.IsComplexNumber(Half.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(One)); + Assert.False(NumberBaseHelper.IsComplexNumber(Half.MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(Half.PositiveInfinity)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.False(NumberBaseHelper.IsEvenInteger(Half.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsEvenInteger(Half.MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(NegativeOne)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-Half.Epsilon)); + Assert.True(NumberBaseHelper.IsEvenInteger(NegativeZero)); + Assert.False(NumberBaseHelper.IsEvenInteger(Half.NaN)); + Assert.True(NumberBaseHelper.IsEvenInteger(Zero)); + Assert.False(NumberBaseHelper.IsEvenInteger(Half.Epsilon)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(One)); + Assert.True(NumberBaseHelper.IsEvenInteger(Half.MaxValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(Half.PositiveInfinity)); + } + [Fact] public static void IsFiniteTest() { @@ -1519,6 +1585,26 @@ public static void IsFiniteTest() Assert.False(NumberBaseHelper.IsFinite(Half.PositiveInfinity)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(Half.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Half.MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NegativeOne)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-Half.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NegativeZero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Half.NaN)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Zero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Half.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(One)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Half.MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Half.PositiveInfinity)); + } + [Fact] public static void IsInfinityTest() { @@ -1539,6 +1625,26 @@ public static void IsInfinityTest() Assert.True(NumberBaseHelper.IsInfinity(Half.PositiveInfinity)); } + [Fact] + public static void IsIntegerTest() + { + Assert.False(NumberBaseHelper.IsInteger(Half.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsInteger(Half.MinValue)); + Assert.True(NumberBaseHelper.IsInteger(NegativeOne)); + Assert.False(NumberBaseHelper.IsInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(-Half.Epsilon)); + Assert.True(NumberBaseHelper.IsInteger(NegativeZero)); + Assert.False(NumberBaseHelper.IsInteger(Half.NaN)); + Assert.True(NumberBaseHelper.IsInteger(Zero)); + Assert.False(NumberBaseHelper.IsInteger(Half.Epsilon)); + Assert.False(NumberBaseHelper.IsInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsInteger(One)); + Assert.True(NumberBaseHelper.IsInteger(Half.MaxValue)); + Assert.False(NumberBaseHelper.IsInteger(Half.PositiveInfinity)); + } + [Fact] public static void IsNaNTest() { @@ -1619,6 +1725,46 @@ public static void IsNormalTest() Assert.False(NumberBaseHelper.IsNormal(Half.PositiveInfinity)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(Half.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsOddInteger(Half.MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(NegativeOne)); + Assert.False(NumberBaseHelper.IsOddInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-Half.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(NegativeZero)); + Assert.False(NumberBaseHelper.IsOddInteger(Half.NaN)); + Assert.False(NumberBaseHelper.IsOddInteger(Zero)); + Assert.False(NumberBaseHelper.IsOddInteger(Half.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsOddInteger(One)); + Assert.False(NumberBaseHelper.IsOddInteger(Half.MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(Half.PositiveInfinity)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.False(NumberBaseHelper.IsPositive(Half.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsPositive(Half.MinValue)); + Assert.False(NumberBaseHelper.IsPositive(NegativeOne)); + Assert.False(NumberBaseHelper.IsPositive(-MinNormal)); + Assert.False(NumberBaseHelper.IsPositive(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositive(-Half.Epsilon)); + Assert.False(NumberBaseHelper.IsPositive(NegativeZero)); + Assert.False(NumberBaseHelper.IsPositive(Half.NaN)); + Assert.True(NumberBaseHelper.IsPositive(Zero)); + Assert.True(NumberBaseHelper.IsPositive(Half.Epsilon)); + Assert.True(NumberBaseHelper.IsPositive(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsPositive(MinNormal)); + Assert.True(NumberBaseHelper.IsPositive(One)); + Assert.True(NumberBaseHelper.IsPositive(Half.MaxValue)); + Assert.True(NumberBaseHelper.IsPositive(Half.PositiveInfinity)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1639,6 +1785,26 @@ public static void IsPositiveInfinityTest() Assert.True(NumberBaseHelper.IsPositiveInfinity(Half.PositiveInfinity)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(Half.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsRealNumber(Half.MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(NegativeOne)); + Assert.True(NumberBaseHelper.IsRealNumber(-MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-Half.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(NegativeZero)); + Assert.False(NumberBaseHelper.IsRealNumber(Half.NaN)); + Assert.True(NumberBaseHelper.IsRealNumber(Zero)); + Assert.True(NumberBaseHelper.IsRealNumber(Half.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(One)); + Assert.True(NumberBaseHelper.IsRealNumber(Half.MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(Half.PositiveInfinity)); + } + [Fact] public static void IsSubnormalTest() { @@ -1659,6 +1825,26 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(Half.PositiveInfinity)); } + [Fact] + public static void IsZeroTest() + { + Assert.False(NumberBaseHelper.IsZero(Half.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsZero(Half.MinValue)); + Assert.False(NumberBaseHelper.IsZero(NegativeOne)); + Assert.False(NumberBaseHelper.IsZero(-MinNormal)); + Assert.False(NumberBaseHelper.IsZero(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(-Half.Epsilon)); + Assert.True(NumberBaseHelper.IsZero(NegativeZero)); + Assert.False(NumberBaseHelper.IsZero(Half.NaN)); + Assert.True(NumberBaseHelper.IsZero(Zero)); + Assert.False(NumberBaseHelper.IsZero(Half.Epsilon)); + Assert.False(NumberBaseHelper.IsZero(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(MinNormal)); + Assert.False(NumberBaseHelper.IsZero(One)); + Assert.False(NumberBaseHelper.IsZero(Half.MaxValue)); + Assert.False(NumberBaseHelper.IsZero(Half.PositiveInfinity)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/Int128Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/Int128Tests.GenericMath.cs index 28b62fae506619..fd057cbb484699 100644 --- a/src/libraries/System.Runtime/tests/System/Int128Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/Int128Tests.GenericMath.cs @@ -594,6 +594,12 @@ public static void OneTest() Assert.Equal(One, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1257,6 +1263,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(Zero)); + Assert.True(NumberBaseHelper.IsCanonical(One)); + Assert.True(NumberBaseHelper.IsCanonical(MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(NegativeOne)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(Zero)); + Assert.False(NumberBaseHelper.IsComplexNumber(One)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(NegativeOne)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger(Zero)); + Assert.False(NumberBaseHelper.IsEvenInteger(One)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxValue)); + Assert.True(NumberBaseHelper.IsEvenInteger(MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(NegativeOne)); + } + [Fact] public static void IsFiniteTest() { @@ -1267,6 +1303,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(NegativeOne)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(Zero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(One)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(NegativeOne)); + } + [Fact] public static void IsInfinityTest() { @@ -1277,6 +1323,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(NegativeOne)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger(Zero)); + Assert.True(NumberBaseHelper.IsInteger(One)); + Assert.True(NumberBaseHelper.IsInteger(MaxValue)); + Assert.True(NumberBaseHelper.IsInteger(MinValue)); + Assert.True(NumberBaseHelper.IsInteger(NegativeOne)); + } + [Fact] public static void IsNaNTest() { @@ -1317,6 +1373,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(NegativeOne)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(Zero)); + Assert.True(NumberBaseHelper.IsOddInteger(One)); + Assert.True(NumberBaseHelper.IsOddInteger(MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(NegativeOne)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive(Zero)); + Assert.True(NumberBaseHelper.IsPositive(One)); + Assert.True(NumberBaseHelper.IsPositive(MaxValue)); + Assert.False(NumberBaseHelper.IsPositive(MinValue)); + Assert.False(NumberBaseHelper.IsPositive(NegativeOne)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1327,6 +1403,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(NegativeOne)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(Zero)); + Assert.True(NumberBaseHelper.IsRealNumber(One)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(NegativeOne)); + } + [Fact] public static void IsSubnormalTest() { @@ -1337,6 +1423,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(NegativeOne)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero(Zero)); + Assert.False(NumberBaseHelper.IsZero(One)); + Assert.False(NumberBaseHelper.IsZero(MaxValue)); + Assert.False(NumberBaseHelper.IsZero(MinValue)); + Assert.False(NumberBaseHelper.IsZero(NegativeOne)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/Int16Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/Int16Tests.GenericMath.cs index f80a850d2ad1d6..a2ca19cf854390 100644 --- a/src/libraries/System.Runtime/tests/System/Int16Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/Int16Tests.GenericMath.cs @@ -544,6 +544,12 @@ public static void OneTest() Assert.Equal((short)0x0001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -956,6 +962,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((short)0x0000)); + Assert.True(NumberBaseHelper.IsCanonical((short)0x0001)); + Assert.True(NumberBaseHelper.IsCanonical((short)0x7FFF)); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((short)0x8000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((short)0xFFFF))); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((short)0x0000)); + Assert.False(NumberBaseHelper.IsComplexNumber((short)0x0001)); + Assert.False(NumberBaseHelper.IsComplexNumber((short)0x7FFF)); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((short)0x8000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((short)0xFFFF))); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((short)0x0000)); + Assert.False(NumberBaseHelper.IsEvenInteger((short)0x0001)); + Assert.False(NumberBaseHelper.IsEvenInteger((short)0x7FFF)); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((short)0x8000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((short)0xFFFF))); + } + [Fact] public static void IsFiniteTest() { @@ -966,6 +1002,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(unchecked((short)0xFFFF))); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((short)0x0000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((short)0x0001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((short)0x7FFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((short)0x8000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((short)0xFFFF))); + } + [Fact] public static void IsInfinityTest() { @@ -976,6 +1022,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(unchecked((short)0xFFFF))); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((short)0x0000)); + Assert.True(NumberBaseHelper.IsInteger((short)0x0001)); + Assert.True(NumberBaseHelper.IsInteger((short)0x7FFF)); + Assert.True(NumberBaseHelper.IsInteger(unchecked((short)0x8000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((short)0xFFFF))); + } + [Fact] public static void IsNaNTest() { @@ -1016,6 +1072,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(unchecked((short)0xFFFF))); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((short)0x0000)); + Assert.True(NumberBaseHelper.IsOddInteger((short)0x0001)); + Assert.True(NumberBaseHelper.IsOddInteger((short)0x7FFF)); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((short)0x8000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((short)0xFFFF))); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((short)0x0000)); + Assert.True(NumberBaseHelper.IsPositive((short)0x0001)); + Assert.True(NumberBaseHelper.IsPositive((short)0x7FFF)); + Assert.False(NumberBaseHelper.IsPositive(unchecked((short)0x8000))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((short)0xFFFF))); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1026,6 +1102,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(unchecked((short)0xFFFF))); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((short)0x0000)); + Assert.True(NumberBaseHelper.IsRealNumber((short)0x0001)); + Assert.True(NumberBaseHelper.IsRealNumber((short)0x7FFF)); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((short)0x8000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((short)0xFFFF))); + } + [Fact] public static void IsSubnormalTest() { @@ -1036,6 +1122,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(unchecked((short)0xFFFF))); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((short)0x0000)); + Assert.False(NumberBaseHelper.IsZero((short)0x0001)); + Assert.False(NumberBaseHelper.IsZero((short)0x7FFF)); + Assert.False(NumberBaseHelper.IsZero(unchecked((short)0x8000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((short)0xFFFF))); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/Int32Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/Int32Tests.GenericMath.cs index 7334a842c74313..4246afdda0fb0c 100644 --- a/src/libraries/System.Runtime/tests/System/Int32Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/Int32Tests.GenericMath.cs @@ -544,6 +544,12 @@ public static void OneTest() Assert.Equal((int)0x00000001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -956,6 +962,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((int)0x00000000)); + Assert.True(NumberBaseHelper.IsCanonical((int)0x00000001)); + Assert.True(NumberBaseHelper.IsCanonical((int)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((int)0x80000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((int)0xFFFFFFFF))); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((int)0x00000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((int)0x00000001)); + Assert.False(NumberBaseHelper.IsComplexNumber((int)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((int)0x80000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((int)0xFFFFFFFF))); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((int)0x00000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((int)0x00000001)); + Assert.False(NumberBaseHelper.IsEvenInteger((int)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((int)0x80000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((int)0xFFFFFFFF))); + } + [Fact] public static void IsFiniteTest() { @@ -966,6 +1002,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(unchecked((int)0xFFFFFFFF))); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((int)0x00000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((int)0x00000001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((int)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((int)0x80000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((int)0xFFFFFFFF))); + } + [Fact] public static void IsInfinityTest() { @@ -976,6 +1022,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(unchecked((int)0xFFFFFFFF))); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((int)0x00000000)); + Assert.True(NumberBaseHelper.IsInteger((int)0x00000001)); + Assert.True(NumberBaseHelper.IsInteger((int)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsInteger(unchecked((int)0x80000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((int)0xFFFFFFFF))); + } + [Fact] public static void IsNaNTest() { @@ -1016,6 +1072,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(unchecked((int)0xFFFFFFFF))); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((int)0x00000000)); + Assert.True(NumberBaseHelper.IsOddInteger((int)0x00000001)); + Assert.True(NumberBaseHelper.IsOddInteger((int)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((int)0x80000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((int)0xFFFFFFFF))); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((int)0x00000000)); + Assert.True(NumberBaseHelper.IsPositive((int)0x00000001)); + Assert.True(NumberBaseHelper.IsPositive((int)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsPositive(unchecked((int)0x80000000))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((int)0xFFFFFFFF))); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1026,6 +1102,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(unchecked((int)0xFFFFFFFF))); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((int)0x00000000)); + Assert.True(NumberBaseHelper.IsRealNumber((int)0x00000001)); + Assert.True(NumberBaseHelper.IsRealNumber((int)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((int)0x80000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((int)0xFFFFFFFF))); + } + [Fact] public static void IsSubnormalTest() { @@ -1036,6 +1122,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(unchecked((int)0xFFFFFFFF))); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((int)0x00000000)); + Assert.False(NumberBaseHelper.IsZero((int)0x00000001)); + Assert.False(NumberBaseHelper.IsZero((int)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsZero(unchecked((int)0x80000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((int)0xFFFFFFFF))); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/Int64Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/Int64Tests.GenericMath.cs index 4b012694a4dcd4..bced25ea60754e 100644 --- a/src/libraries/System.Runtime/tests/System/Int64Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/Int64Tests.GenericMath.cs @@ -544,6 +544,12 @@ public static void OneTest() Assert.Equal((long)0x0000000000000001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -956,6 +962,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((long)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsCanonical((long)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsCanonical((long)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((long)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((long)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((long)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsComplexNumber((long)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((long)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((long)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((long)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsEvenInteger((long)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((long)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + [Fact] public static void IsFiniteTest() { @@ -966,6 +1002,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(unchecked((long)0xFFFFFFFFFFFFFFFF))); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((long)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((long)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((long)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((long)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + [Fact] public static void IsInfinityTest() { @@ -976,6 +1022,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(unchecked((long)0xFFFFFFFFFFFFFFFF))); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((long)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsInteger((long)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsInteger((long)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsInteger(unchecked((long)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + [Fact] public static void IsNaNTest() { @@ -1016,6 +1072,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(unchecked((long)0xFFFFFFFFFFFFFFFF))); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((long)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsOddInteger((long)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsOddInteger((long)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((long)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((long)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsPositive((long)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsPositive((long)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsPositive(unchecked((long)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1026,6 +1102,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(unchecked((long)0xFFFFFFFFFFFFFFFF))); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((long)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsRealNumber((long)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsRealNumber((long)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((long)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + [Fact] public static void IsSubnormalTest() { @@ -1036,6 +1122,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(unchecked((long)0xFFFFFFFFFFFFFFFF))); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((long)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsZero((long)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsZero((long)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsZero(unchecked((long)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((long)0xFFFFFFFFFFFFFFFF))); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/IntPtrTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/IntPtrTests.GenericMath.cs index dbd9a2816004f1..6817debb45ef9b 100644 --- a/src/libraries/System.Runtime/tests/System/IntPtrTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/IntPtrTests.GenericMath.cs @@ -1040,6 +1040,12 @@ public static void OneTest() Assert.Equal((nint)0x00000001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1573,6 +1579,69 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsCanonical((nint)0x00000000)); + Assert.True(NumberBaseHelper.IsCanonical((nint)0x00000001)); + Assert.True(NumberBaseHelper.IsCanonical((nint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0x80000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nint)0xFFFFFFFF))); + } + } + + [Fact] + public static void IsComplexNumberTest() + { + if (Environment.Is64BitProcess) + { + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.False(NumberBaseHelper.IsComplexNumber((nint)0x00000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((nint)0x00000001)); + Assert.False(NumberBaseHelper.IsComplexNumber((nint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0x80000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nint)0xFFFFFFFF))); + } + } + + [Fact] + public static void IsEvenIntegerTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((nint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((nint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsEvenInteger((nint)0x00000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((nint)0x00000001)); + Assert.False(NumberBaseHelper.IsEvenInteger((nint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((nint)0x80000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nint)0xFFFFFFFF))); + } + } + [Fact] public static void IsFiniteTest() { @@ -1594,6 +1663,27 @@ public static void IsFiniteTest() } } + [Fact] + public static void IsImaginaryNumberTest() + { + if (Environment.Is64BitProcess) + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((nint)0x00000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((nint)0x00000001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((nint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0x80000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nint)0xFFFFFFFF))); + } + } + [Fact] public static void IsInfinityTest() { @@ -1615,6 +1705,27 @@ public static void IsInfinityTest() } } + [Fact] + public static void IsIntegerTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsInteger((nint)0x00000000)); + Assert.True(NumberBaseHelper.IsInteger((nint)0x00000001)); + Assert.True(NumberBaseHelper.IsInteger((nint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0x80000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nint)0xFFFFFFFF))); + } + } + [Fact] public static void IsNaNTest() { @@ -1699,6 +1810,48 @@ public static void IsNormalTest() } } + [Fact] + public static void IsOddIntegerTest() + { + if (Environment.Is64BitProcess) + { + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((nint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((nint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.False(NumberBaseHelper.IsOddInteger((nint)0x00000000)); + Assert.True(NumberBaseHelper.IsOddInteger((nint)0x00000001)); + Assert.True(NumberBaseHelper.IsOddInteger((nint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((nint)0x80000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nint)0xFFFFFFFF))); + } + } + + [Fact] + public static void IsPositiveTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsPositive(unchecked((nint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsPositive(unchecked((nint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsPositive(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((nint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsPositive((nint)0x00000000)); + Assert.True(NumberBaseHelper.IsPositive((nint)0x00000001)); + Assert.True(NumberBaseHelper.IsPositive((nint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsPositive(unchecked((nint)0x80000000))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((nint)0xFFFFFFFF))); + } + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1720,6 +1873,27 @@ public static void IsPositiveInfinityTest() } } + [Fact] + public static void IsRealNumberTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsRealNumber((nint)0x00000000)); + Assert.True(NumberBaseHelper.IsRealNumber((nint)0x00000001)); + Assert.True(NumberBaseHelper.IsRealNumber((nint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0x80000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nint)0xFFFFFFFF))); + } + } + [Fact] public static void IsSubnormalTest() { @@ -1741,6 +1915,27 @@ public static void IsSubnormalTest() } } + [Fact] + public static void IsZeroTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsZero(unchecked((nint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsZero((nint)0x00000000)); + Assert.False(NumberBaseHelper.IsZero((nint)0x00000001)); + Assert.False(NumberBaseHelper.IsZero((nint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsZero(unchecked((nint)0x80000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nint)0xFFFFFFFF))); + } + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/SByteTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/SByteTests.GenericMath.cs index e458b6a2f28bee..b0be250fc68892 100644 --- a/src/libraries/System.Runtime/tests/System/SByteTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/SByteTests.GenericMath.cs @@ -544,6 +544,12 @@ public static void OneTest() Assert.Equal((sbyte)0x01, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -956,6 +962,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((sbyte)0x00)); + Assert.True(NumberBaseHelper.IsCanonical((sbyte)0x01)); + Assert.True(NumberBaseHelper.IsCanonical((sbyte)0x7F)); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((sbyte)0x80))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((sbyte)0xFF))); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((sbyte)0x00)); + Assert.False(NumberBaseHelper.IsComplexNumber((sbyte)0x01)); + Assert.False(NumberBaseHelper.IsComplexNumber((sbyte)0x7F)); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((sbyte)0x80))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((sbyte)0xFF))); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((sbyte)0x00)); + Assert.False(NumberBaseHelper.IsEvenInteger((sbyte)0x01)); + Assert.False(NumberBaseHelper.IsEvenInteger((sbyte)0x7F)); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((sbyte)0x80))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((sbyte)0xFF))); + } + [Fact] public static void IsFiniteTest() { @@ -966,6 +1002,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(unchecked((sbyte)0xFF))); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((sbyte)0x00)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((sbyte)0x01)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((sbyte)0x7F)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((sbyte)0x80))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((sbyte)0xFF))); + } + [Fact] public static void IsInfinityTest() { @@ -976,6 +1022,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(unchecked((sbyte)0xFF))); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((sbyte)0x00)); + Assert.True(NumberBaseHelper.IsInteger((sbyte)0x01)); + Assert.True(NumberBaseHelper.IsInteger((sbyte)0x7F)); + Assert.True(NumberBaseHelper.IsInteger(unchecked((sbyte)0x80))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((sbyte)0xFF))); + } + [Fact] public static void IsNaNTest() { @@ -1016,6 +1072,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(unchecked((sbyte)0xFF))); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((sbyte)0x00)); + Assert.True(NumberBaseHelper.IsOddInteger((sbyte)0x01)); + Assert.True(NumberBaseHelper.IsOddInteger((sbyte)0x7F)); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((sbyte)0x80))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((sbyte)0xFF))); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((sbyte)0x00)); + Assert.True(NumberBaseHelper.IsPositive((sbyte)0x01)); + Assert.True(NumberBaseHelper.IsPositive((sbyte)0x7F)); + Assert.False(NumberBaseHelper.IsPositive(unchecked((sbyte)0x80))); + Assert.False(NumberBaseHelper.IsPositive(unchecked((sbyte)0xFF))); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1026,6 +1102,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(unchecked((sbyte)0xFF))); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((sbyte)0x00)); + Assert.True(NumberBaseHelper.IsRealNumber((sbyte)0x01)); + Assert.True(NumberBaseHelper.IsRealNumber((sbyte)0x7F)); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((sbyte)0x80))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((sbyte)0xFF))); + } + [Fact] public static void IsSubnormalTest() { @@ -1036,6 +1122,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(unchecked((sbyte)0xFF))); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((sbyte)0x00)); + Assert.False(NumberBaseHelper.IsZero((sbyte)0x01)); + Assert.False(NumberBaseHelper.IsZero((sbyte)0x7F)); + Assert.False(NumberBaseHelper.IsZero(unchecked((sbyte)0x80))); + Assert.False(NumberBaseHelper.IsZero(unchecked((sbyte)0xFF))); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/SingleTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/SingleTests.GenericMath.cs index fcc58e8f9fd9e8..4692ecfe55ee40 100644 --- a/src/libraries/System.Runtime/tests/System/SingleTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/SingleTests.GenericMath.cs @@ -987,6 +987,12 @@ public static void OneTest() AssertBitwiseEqual(1.0f, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1481,6 +1487,66 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(float.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsCanonical(float.MinValue)); + Assert.True(NumberBaseHelper.IsCanonical(-1.0f)); + Assert.True(NumberBaseHelper.IsCanonical(-MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(-float.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(-0.0f)); + Assert.True(NumberBaseHelper.IsCanonical(float.NaN)); + Assert.True(NumberBaseHelper.IsCanonical(0.0f)); + Assert.True(NumberBaseHelper.IsCanonical(float.Epsilon)); + Assert.True(NumberBaseHelper.IsCanonical(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsCanonical(MinNormal)); + Assert.True(NumberBaseHelper.IsCanonical(1.0f)); + Assert.True(NumberBaseHelper.IsCanonical(float.MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(float.PositiveInfinity)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(float.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsComplexNumber(float.MinValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(-1.0f)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(-float.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(-0.0f)); + Assert.False(NumberBaseHelper.IsComplexNumber(float.NaN)); + Assert.False(NumberBaseHelper.IsComplexNumber(0.0f)); + Assert.False(NumberBaseHelper.IsComplexNumber(float.Epsilon)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsComplexNumber(1.0f)); + Assert.False(NumberBaseHelper.IsComplexNumber(float.MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(float.PositiveInfinity)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.False(NumberBaseHelper.IsEvenInteger(float.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsEvenInteger(float.MinValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(-1.0f)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(-float.Epsilon)); + Assert.True(NumberBaseHelper.IsEvenInteger(-0.0f)); + Assert.False(NumberBaseHelper.IsEvenInteger(float.NaN)); + Assert.True(NumberBaseHelper.IsEvenInteger(0.0f)); + Assert.False(NumberBaseHelper.IsEvenInteger(float.Epsilon)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(MinNormal)); + Assert.False(NumberBaseHelper.IsEvenInteger(1.0f)); + Assert.True(NumberBaseHelper.IsEvenInteger(float.MaxValue)); + Assert.False(NumberBaseHelper.IsEvenInteger(float.PositiveInfinity)); + } + [Fact] public static void IsFiniteTest() { @@ -1501,6 +1567,26 @@ public static void IsFiniteTest() Assert.False(NumberBaseHelper.IsFinite(float.PositiveInfinity)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(float.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(float.MinValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-1.0f)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-float.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(-0.0f)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(float.NaN)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(0.0f)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(float.Epsilon)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MinNormal)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(1.0f)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(float.MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(float.PositiveInfinity)); + } + [Fact] public static void IsInfinityTest() { @@ -1521,6 +1607,26 @@ public static void IsInfinityTest() Assert.True(NumberBaseHelper.IsInfinity(float.PositiveInfinity)); } + [Fact] + public static void IsIntegerTest() + { + Assert.False(NumberBaseHelper.IsInteger(float.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsInteger(float.MinValue)); + Assert.True(NumberBaseHelper.IsInteger(-1.0f)); + Assert.False(NumberBaseHelper.IsInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(-float.Epsilon)); + Assert.True(NumberBaseHelper.IsInteger(-0.0f)); + Assert.False(NumberBaseHelper.IsInteger(float.NaN)); + Assert.True(NumberBaseHelper.IsInteger(0.0f)); + Assert.False(NumberBaseHelper.IsInteger(float.Epsilon)); + Assert.False(NumberBaseHelper.IsInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsInteger(1.0f)); + Assert.True(NumberBaseHelper.IsInteger(float.MaxValue)); + Assert.False(NumberBaseHelper.IsInteger(float.PositiveInfinity)); + } + [Fact] public static void IsNaNTest() { @@ -1601,6 +1707,46 @@ public static void IsNormalTest() Assert.False(NumberBaseHelper.IsNormal(float.PositiveInfinity)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(float.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsOddInteger(float.MinValue)); + Assert.True(NumberBaseHelper.IsOddInteger(-1.0f)); + Assert.False(NumberBaseHelper.IsOddInteger(-MinNormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(-float.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(-0.0f)); + Assert.False(NumberBaseHelper.IsOddInteger(float.NaN)); + Assert.False(NumberBaseHelper.IsOddInteger(0.0f)); + Assert.False(NumberBaseHelper.IsOddInteger(float.Epsilon)); + Assert.False(NumberBaseHelper.IsOddInteger(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsOddInteger(MinNormal)); + Assert.True(NumberBaseHelper.IsOddInteger(1.0f)); + Assert.False(NumberBaseHelper.IsOddInteger(float.MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(float.PositiveInfinity)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.False(NumberBaseHelper.IsPositive(float.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsPositive(float.MinValue)); + Assert.False(NumberBaseHelper.IsPositive(-1.0f)); + Assert.False(NumberBaseHelper.IsPositive(-MinNormal)); + Assert.False(NumberBaseHelper.IsPositive(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsPositive(-float.Epsilon)); + Assert.False(NumberBaseHelper.IsPositive(-0.0f)); + Assert.False(NumberBaseHelper.IsPositive(float.NaN)); + Assert.True(NumberBaseHelper.IsPositive(0.0f)); + Assert.True(NumberBaseHelper.IsPositive(float.Epsilon)); + Assert.True(NumberBaseHelper.IsPositive(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsPositive(MinNormal)); + Assert.True(NumberBaseHelper.IsPositive(1.0f)); + Assert.True(NumberBaseHelper.IsPositive(float.MaxValue)); + Assert.True(NumberBaseHelper.IsPositive(float.PositiveInfinity)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1621,6 +1767,26 @@ public static void IsPositiveInfinityTest() Assert.True(NumberBaseHelper.IsPositiveInfinity(float.PositiveInfinity)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(float.NegativeInfinity)); + Assert.True(NumberBaseHelper.IsRealNumber(float.MinValue)); + Assert.True(NumberBaseHelper.IsRealNumber(-1.0f)); + Assert.True(NumberBaseHelper.IsRealNumber(-MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(-float.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(-0.0f)); + Assert.False(NumberBaseHelper.IsRealNumber(float.NaN)); + Assert.True(NumberBaseHelper.IsRealNumber(0.0f)); + Assert.True(NumberBaseHelper.IsRealNumber(float.Epsilon)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxSubnormal)); + Assert.True(NumberBaseHelper.IsRealNumber(MinNormal)); + Assert.True(NumberBaseHelper.IsRealNumber(1.0f)); + Assert.True(NumberBaseHelper.IsRealNumber(float.MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(float.PositiveInfinity)); + } + [Fact] public static void IsSubnormalTest() { @@ -1641,6 +1807,26 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(float.PositiveInfinity)); } + [Fact] + public static void IsZeroTest() + { + Assert.False(NumberBaseHelper.IsZero(float.NegativeInfinity)); + Assert.False(NumberBaseHelper.IsZero(float.MinValue)); + Assert.False(NumberBaseHelper.IsZero(-1.0f)); + Assert.False(NumberBaseHelper.IsZero(-MinNormal)); + Assert.False(NumberBaseHelper.IsZero(-MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(-float.Epsilon)); + Assert.True(NumberBaseHelper.IsZero(-0.0f)); + Assert.False(NumberBaseHelper.IsZero(float.NaN)); + Assert.True(NumberBaseHelper.IsZero(0.0f)); + Assert.False(NumberBaseHelper.IsZero(float.Epsilon)); + Assert.False(NumberBaseHelper.IsZero(MaxSubnormal)); + Assert.False(NumberBaseHelper.IsZero(MinNormal)); + Assert.False(NumberBaseHelper.IsZero(1.0f)); + Assert.False(NumberBaseHelper.IsZero(float.MaxValue)); + Assert.False(NumberBaseHelper.IsZero(float.PositiveInfinity)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/UInt128Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/UInt128Tests.GenericMath.cs index 3fbe0593b2e29d..c572abcf2a673f 100644 --- a/src/libraries/System.Runtime/tests/System/UInt128Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/UInt128Tests.GenericMath.cs @@ -593,6 +593,12 @@ public static void OneTest() Assert.Equal(One, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1230,6 +1236,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical(Zero)); + Assert.True(NumberBaseHelper.IsCanonical(One)); + Assert.True(NumberBaseHelper.IsCanonical(Int128MaxValue)); + Assert.True(NumberBaseHelper.IsCanonical(Int128MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsCanonical(MaxValue)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber(Zero)); + Assert.False(NumberBaseHelper.IsComplexNumber(One)); + Assert.False(NumberBaseHelper.IsComplexNumber(Int128MaxValue)); + Assert.False(NumberBaseHelper.IsComplexNumber(Int128MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsComplexNumber(MaxValue)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger(Zero)); + Assert.False(NumberBaseHelper.IsEvenInteger(One)); + Assert.False(NumberBaseHelper.IsEvenInteger(Int128MaxValue)); + Assert.True(NumberBaseHelper.IsEvenInteger(Int128MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsEvenInteger(MaxValue)); + } + [Fact] public static void IsFiniteTest() { @@ -1240,6 +1276,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite(MaxValue)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(Zero)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(One)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Int128MaxValue)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(Int128MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsImaginaryNumber(MaxValue)); + } + [Fact] public static void IsInfinityTest() { @@ -1250,6 +1296,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity(MaxValue)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger(Zero)); + Assert.True(NumberBaseHelper.IsInteger(One)); + Assert.True(NumberBaseHelper.IsInteger(Int128MaxValue)); + Assert.True(NumberBaseHelper.IsInteger(Int128MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsInteger(MaxValue)); + } + [Fact] public static void IsNaNTest() { @@ -1290,6 +1346,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal(MaxValue)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger(Zero)); + Assert.True(NumberBaseHelper.IsOddInteger(One)); + Assert.True(NumberBaseHelper.IsOddInteger(Int128MaxValue)); + Assert.False(NumberBaseHelper.IsOddInteger(Int128MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsOddInteger(MaxValue)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive(Zero)); + Assert.True(NumberBaseHelper.IsPositive(One)); + Assert.True(NumberBaseHelper.IsPositive(Int128MaxValue)); + Assert.True(NumberBaseHelper.IsPositive(Int128MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsPositive(MaxValue)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1300,6 +1376,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity(MaxValue)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber(Zero)); + Assert.True(NumberBaseHelper.IsRealNumber(One)); + Assert.True(NumberBaseHelper.IsRealNumber(Int128MaxValue)); + Assert.True(NumberBaseHelper.IsRealNumber(Int128MaxValuePlusOne)); + Assert.True(NumberBaseHelper.IsRealNumber(MaxValue)); + } + [Fact] public static void IsSubnormalTest() { @@ -1310,6 +1396,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal(MaxValue)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero(Zero)); + Assert.False(NumberBaseHelper.IsZero(One)); + Assert.False(NumberBaseHelper.IsZero(Int128MaxValue)); + Assert.False(NumberBaseHelper.IsZero(Int128MaxValuePlusOne)); + Assert.False(NumberBaseHelper.IsZero(MaxValue)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/UInt16Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/UInt16Tests.GenericMath.cs index 1e3f6cae029385..1cb5e4388ea3b8 100644 --- a/src/libraries/System.Runtime/tests/System/UInt16Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/UInt16Tests.GenericMath.cs @@ -544,6 +544,12 @@ public static void OneTest() Assert.Equal((ushort)0x0001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -956,6 +962,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((ushort)0x0000)); + Assert.True(NumberBaseHelper.IsCanonical((ushort)0x0001)); + Assert.True(NumberBaseHelper.IsCanonical((ushort)0x7FFF)); + Assert.True(NumberBaseHelper.IsCanonical((ushort)0x8000)); + Assert.True(NumberBaseHelper.IsCanonical((ushort)0xFFFF)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((ushort)0x0000)); + Assert.False(NumberBaseHelper.IsComplexNumber((ushort)0x0001)); + Assert.False(NumberBaseHelper.IsComplexNumber((ushort)0x7FFF)); + Assert.False(NumberBaseHelper.IsComplexNumber((ushort)0x8000)); + Assert.False(NumberBaseHelper.IsComplexNumber((ushort)0xFFFF)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((ushort)0x0000)); + Assert.False(NumberBaseHelper.IsEvenInteger((ushort)0x0001)); + Assert.False(NumberBaseHelper.IsEvenInteger((ushort)0x7FFF)); + Assert.True(NumberBaseHelper.IsEvenInteger((ushort)0x8000)); + Assert.False(NumberBaseHelper.IsEvenInteger((ushort)0xFFFF)); + } + [Fact] public static void IsFiniteTest() { @@ -966,6 +1002,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite((ushort)0xFFFF)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((ushort)0x0000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ushort)0x0001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ushort)0x7FFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ushort)0x8000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ushort)0xFFFF)); + } + [Fact] public static void IsInfinityTest() { @@ -976,6 +1022,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity((ushort)0xFFFF)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((ushort)0x0000)); + Assert.True(NumberBaseHelper.IsInteger((ushort)0x0001)); + Assert.True(NumberBaseHelper.IsInteger((ushort)0x7FFF)); + Assert.True(NumberBaseHelper.IsInteger((ushort)0x8000)); + Assert.True(NumberBaseHelper.IsInteger((ushort)0xFFFF)); + } + [Fact] public static void IsNaNTest() { @@ -1016,6 +1072,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal((ushort)0xFFFF)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((ushort)0x0000)); + Assert.True(NumberBaseHelper.IsOddInteger((ushort)0x0001)); + Assert.True(NumberBaseHelper.IsOddInteger((ushort)0x7FFF)); + Assert.False(NumberBaseHelper.IsOddInteger((ushort)0x8000)); + Assert.True(NumberBaseHelper.IsOddInteger((ushort)0xFFFF)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((ushort)0x0000)); + Assert.True(NumberBaseHelper.IsPositive((ushort)0x0001)); + Assert.True(NumberBaseHelper.IsPositive((ushort)0x7FFF)); + Assert.True(NumberBaseHelper.IsPositive((ushort)0x8000)); + Assert.True(NumberBaseHelper.IsPositive((ushort)0xFFFF)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1026,6 +1102,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity((ushort)0xFFFF)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((ushort)0x0000)); + Assert.True(NumberBaseHelper.IsRealNumber((ushort)0x0001)); + Assert.True(NumberBaseHelper.IsRealNumber((ushort)0x7FFF)); + Assert.True(NumberBaseHelper.IsRealNumber((ushort)0x8000)); + Assert.True(NumberBaseHelper.IsRealNumber((ushort)0xFFFF)); + } + [Fact] public static void IsSubnormalTest() { @@ -1036,6 +1122,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal((ushort)0xFFFF)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((ushort)0x0000)); + Assert.False(NumberBaseHelper.IsZero((ushort)0x0001)); + Assert.False(NumberBaseHelper.IsZero((ushort)0x7FFF)); + Assert.False(NumberBaseHelper.IsZero((ushort)0x8000)); + Assert.False(NumberBaseHelper.IsZero((ushort)0xFFFF)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/UInt32Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/UInt32Tests.GenericMath.cs index f2fd6d543cd02f..06ee6bd14d3319 100644 --- a/src/libraries/System.Runtime/tests/System/UInt32Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/UInt32Tests.GenericMath.cs @@ -545,6 +545,12 @@ public static void OneTest() Assert.Equal((uint)0x00000001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -957,6 +963,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((uint)0x00000000)); + Assert.True(NumberBaseHelper.IsCanonical((uint)0x00000001)); + Assert.True(NumberBaseHelper.IsCanonical((uint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsCanonical((uint)0x80000000)); + Assert.True(NumberBaseHelper.IsCanonical((uint)0xFFFFFFFF)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((uint)0x00000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((uint)0x00000001)); + Assert.False(NumberBaseHelper.IsComplexNumber((uint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsComplexNumber((uint)0x80000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((uint)0xFFFFFFFF)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((uint)0x00000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((uint)0x00000001)); + Assert.False(NumberBaseHelper.IsEvenInteger((uint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsEvenInteger((uint)0x80000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((uint)0xFFFFFFFF)); + } + [Fact] public static void IsFiniteTest() { @@ -967,6 +1003,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite((uint)0xFFFFFFFF)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((uint)0x00000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((uint)0x00000001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((uint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((uint)0x80000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((uint)0xFFFFFFFF)); + } + [Fact] public static void IsInfinityTest() { @@ -977,6 +1023,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity((uint)0xFFFFFFFF)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((uint)0x00000000)); + Assert.True(NumberBaseHelper.IsInteger((uint)0x00000001)); + Assert.True(NumberBaseHelper.IsInteger((uint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsInteger((uint)0x80000000)); + Assert.True(NumberBaseHelper.IsInteger((uint)0xFFFFFFFF)); + } + [Fact] public static void IsNaNTest() { @@ -1017,6 +1073,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal((uint)0xFFFFFFFF)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((uint)0x00000000)); + Assert.True(NumberBaseHelper.IsOddInteger((uint)0x00000001)); + Assert.True(NumberBaseHelper.IsOddInteger((uint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsOddInteger((uint)0x80000000)); + Assert.True(NumberBaseHelper.IsOddInteger((uint)0xFFFFFFFF)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((uint)0x00000000)); + Assert.True(NumberBaseHelper.IsPositive((uint)0x00000001)); + Assert.True(NumberBaseHelper.IsPositive((uint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsPositive((uint)0x80000000)); + Assert.True(NumberBaseHelper.IsPositive((uint)0xFFFFFFFF)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1027,6 +1103,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity((uint)0xFFFFFFFF)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((uint)0x00000000)); + Assert.True(NumberBaseHelper.IsRealNumber((uint)0x00000001)); + Assert.True(NumberBaseHelper.IsRealNumber((uint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsRealNumber((uint)0x80000000)); + Assert.True(NumberBaseHelper.IsRealNumber((uint)0xFFFFFFFF)); + } + [Fact] public static void IsSubnormalTest() { @@ -1037,6 +1123,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal((uint)0xFFFFFFFF)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((uint)0x00000000)); + Assert.False(NumberBaseHelper.IsZero((uint)0x00000001)); + Assert.False(NumberBaseHelper.IsZero((uint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsZero((uint)0x80000000)); + Assert.False(NumberBaseHelper.IsZero((uint)0xFFFFFFFF)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/UInt64Tests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/UInt64Tests.GenericMath.cs index 5676dcf68e5ac2..71a99821a98c94 100644 --- a/src/libraries/System.Runtime/tests/System/UInt64Tests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/UInt64Tests.GenericMath.cs @@ -543,6 +543,12 @@ public static void OneTest() Assert.Equal((ulong)0x0000000000000001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -955,6 +961,36 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + Assert.True(NumberBaseHelper.IsCanonical((ulong)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsCanonical((ulong)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsCanonical((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsCanonical((ulong)0x8000000000000000)); + Assert.True(NumberBaseHelper.IsCanonical((ulong)0xFFFFFFFFFFFFFFFF)); + } + + [Fact] + public static void IsComplexNumberTest() + { + Assert.False(NumberBaseHelper.IsComplexNumber((ulong)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((ulong)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsComplexNumber((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsComplexNumber((ulong)0x8000000000000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((ulong)0xFFFFFFFFFFFFFFFF)); + } + + [Fact] + public static void IsEvenIntegerTest() + { + Assert.True(NumberBaseHelper.IsEvenInteger((ulong)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((ulong)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsEvenInteger((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsEvenInteger((ulong)0x8000000000000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((ulong)0xFFFFFFFFFFFFFFFF)); + } + [Fact] public static void IsFiniteTest() { @@ -965,6 +1001,16 @@ public static void IsFiniteTest() Assert.True(NumberBaseHelper.IsFinite((ulong)0xFFFFFFFFFFFFFFFF)); } + [Fact] + public static void IsImaginaryNumberTest() + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((ulong)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ulong)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ulong)0x8000000000000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((ulong)0xFFFFFFFFFFFFFFFF)); + } + [Fact] public static void IsInfinityTest() { @@ -975,6 +1021,16 @@ public static void IsInfinityTest() Assert.False(NumberBaseHelper.IsInfinity((ulong)0xFFFFFFFFFFFFFFFF)); } + [Fact] + public static void IsIntegerTest() + { + Assert.True(NumberBaseHelper.IsInteger((ulong)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsInteger((ulong)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsInteger((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsInteger((ulong)0x8000000000000000)); + Assert.True(NumberBaseHelper.IsInteger((ulong)0xFFFFFFFFFFFFFFFF)); + } + [Fact] public static void IsNaNTest() { @@ -1015,6 +1071,26 @@ public static void IsNormalTest() Assert.True(NumberBaseHelper.IsNormal((ulong)0xFFFFFFFFFFFFFFFF)); } + [Fact] + public static void IsOddIntegerTest() + { + Assert.False(NumberBaseHelper.IsOddInteger((ulong)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsOddInteger((ulong)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsOddInteger((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsOddInteger((ulong)0x8000000000000000)); + Assert.True(NumberBaseHelper.IsOddInteger((ulong)0xFFFFFFFFFFFFFFFF)); + } + + [Fact] + public static void IsPositiveTest() + { + Assert.True(NumberBaseHelper.IsPositive((ulong)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsPositive((ulong)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsPositive((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsPositive((ulong)0x8000000000000000)); + Assert.True(NumberBaseHelper.IsPositive((ulong)0xFFFFFFFFFFFFFFFF)); + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1025,6 +1101,16 @@ public static void IsPositiveInfinityTest() Assert.False(NumberBaseHelper.IsPositiveInfinity((ulong)0xFFFFFFFFFFFFFFFF)); } + [Fact] + public static void IsRealNumberTest() + { + Assert.True(NumberBaseHelper.IsRealNumber((ulong)0x0000000000000000)); + Assert.True(NumberBaseHelper.IsRealNumber((ulong)0x0000000000000001)); + Assert.True(NumberBaseHelper.IsRealNumber((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.True(NumberBaseHelper.IsRealNumber((ulong)0x8000000000000000)); + Assert.True(NumberBaseHelper.IsRealNumber((ulong)0xFFFFFFFFFFFFFFFF)); + } + [Fact] public static void IsSubnormalTest() { @@ -1035,6 +1121,16 @@ public static void IsSubnormalTest() Assert.False(NumberBaseHelper.IsSubnormal((ulong)0xFFFFFFFFFFFFFFFF)); } + [Fact] + public static void IsZeroTest() + { + Assert.True(NumberBaseHelper.IsZero((ulong)0x0000000000000000)); + Assert.False(NumberBaseHelper.IsZero((ulong)0x0000000000000001)); + Assert.False(NumberBaseHelper.IsZero((ulong)0x7FFFFFFFFFFFFFFF)); + Assert.False(NumberBaseHelper.IsZero((ulong)0x8000000000000000)); + Assert.False(NumberBaseHelper.IsZero((ulong)0xFFFFFFFFFFFFFFFF)); + } + [Fact] public static void MaxMagnitudeTest() { diff --git a/src/libraries/System.Runtime/tests/System/UIntPtrTests.GenericMath.cs b/src/libraries/System.Runtime/tests/System/UIntPtrTests.GenericMath.cs index bcf3b3e7e0b71f..7cba3bc55eb6b9 100644 --- a/src/libraries/System.Runtime/tests/System/UIntPtrTests.GenericMath.cs +++ b/src/libraries/System.Runtime/tests/System/UIntPtrTests.GenericMath.cs @@ -1032,6 +1032,12 @@ public static void OneTest() Assert.Equal((nuint)0x00000001, NumberBaseHelper.One); } + [Fact] + public static void RadixTest() + { + Assert.Equal(2, NumberBaseHelper.Radix); + } + [Fact] public static void ZeroTest() { @@ -1554,6 +1560,69 @@ public static void CreateTruncatingFromUIntPtrTest() } } + [Fact] + public static void IsCanonicalTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nuint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nuint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nuint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsCanonical(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsCanonical((nuint)0x00000000)); + Assert.True(NumberBaseHelper.IsCanonical((nuint)0x00000001)); + Assert.True(NumberBaseHelper.IsCanonical((nuint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsCanonical((nuint)0x80000000)); + Assert.True(NumberBaseHelper.IsCanonical((nuint)0xFFFFFFFF)); + } + } + + [Fact] + public static void IsComplexNumberTest() + { + if (Environment.Is64BitProcess) + { + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nuint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nuint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nuint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsComplexNumber(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.False(NumberBaseHelper.IsComplexNumber((nuint)0x00000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((nuint)0x00000001)); + Assert.False(NumberBaseHelper.IsComplexNumber((nuint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsComplexNumber((nuint)0x80000000)); + Assert.False(NumberBaseHelper.IsComplexNumber((nuint)0xFFFFFFFF)); + } + } + + [Fact] + public static void IsEvenIntegerTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((nuint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nuint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsEvenInteger(unchecked((nuint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsEvenInteger(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsEvenInteger((nuint)0x00000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((nuint)0x00000001)); + Assert.False(NumberBaseHelper.IsEvenInteger((nuint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsEvenInteger((nuint)0x80000000)); + Assert.False(NumberBaseHelper.IsEvenInteger((nuint)0xFFFFFFFF)); + } + } + [Fact] public static void IsFiniteTest() { @@ -1575,6 +1644,27 @@ public static void IsFiniteTest() } } + [Fact] + public static void IsImaginaryNumberTest() + { + if (Environment.Is64BitProcess) + { + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nuint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nuint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nuint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsImaginaryNumber(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.False(NumberBaseHelper.IsImaginaryNumber((nuint)0x00000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((nuint)0x00000001)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((nuint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((nuint)0x80000000)); + Assert.False(NumberBaseHelper.IsImaginaryNumber((nuint)0xFFFFFFFF)); + } + } + [Fact] public static void IsInfinityTest() { @@ -1596,6 +1686,27 @@ public static void IsInfinityTest() } } + [Fact] + public static void IsIntegerTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsInteger(unchecked((nuint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nuint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nuint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsInteger(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsInteger((nuint)0x00000000)); + Assert.True(NumberBaseHelper.IsInteger((nuint)0x00000001)); + Assert.True(NumberBaseHelper.IsInteger((nuint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsInteger((nuint)0x80000000)); + Assert.True(NumberBaseHelper.IsInteger((nuint)0xFFFFFFFF)); + } + } + [Fact] public static void IsNaNTest() { @@ -1680,6 +1791,48 @@ public static void IsNormalTest() } } + [Fact] + public static void IsOddIntegerTest() + { + if (Environment.Is64BitProcess) + { + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((nuint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nuint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsOddInteger(unchecked((nuint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsOddInteger(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.False(NumberBaseHelper.IsOddInteger((nuint)0x00000000)); + Assert.True(NumberBaseHelper.IsOddInteger((nuint)0x00000001)); + Assert.True(NumberBaseHelper.IsOddInteger((nuint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsOddInteger((nuint)0x80000000)); + Assert.True(NumberBaseHelper.IsOddInteger((nuint)0xFFFFFFFF)); + } + } + + [Fact] + public static void IsPositiveTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsPositive(unchecked((nuint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsPositive(unchecked((nuint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsPositive(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsPositive(unchecked((nuint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsPositive(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsPositive((nuint)0x00000000)); + Assert.True(NumberBaseHelper.IsPositive((nuint)0x00000001)); + Assert.True(NumberBaseHelper.IsPositive((nuint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsPositive((nuint)0x80000000)); + Assert.True(NumberBaseHelper.IsPositive((nuint)0xFFFFFFFF)); + } + } + [Fact] public static void IsPositiveInfinityTest() { @@ -1701,6 +1854,27 @@ public static void IsPositiveInfinityTest() } } + [Fact] + public static void IsRealNumberTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nuint)0x0000000000000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nuint)0x0000000000000001))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nuint)0x8000000000000000))); + Assert.True(NumberBaseHelper.IsRealNumber(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsRealNumber((nuint)0x00000000)); + Assert.True(NumberBaseHelper.IsRealNumber((nuint)0x00000001)); + Assert.True(NumberBaseHelper.IsRealNumber((nuint)0x7FFFFFFF)); + Assert.True(NumberBaseHelper.IsRealNumber((nuint)0x80000000)); + Assert.True(NumberBaseHelper.IsRealNumber((nuint)0xFFFFFFFF)); + } + } + [Fact] public static void IsSubnormalTest() { @@ -1722,6 +1896,27 @@ public static void IsSubnormalTest() } } + [Fact] + public static void IsZeroTest() + { + if (Environment.Is64BitProcess) + { + Assert.True(NumberBaseHelper.IsZero(unchecked((nuint)0x0000000000000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nuint)0x0000000000000001))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nuint)0x8000000000000000))); + Assert.False(NumberBaseHelper.IsZero(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); + } + else + { + Assert.True(NumberBaseHelper.IsZero((nuint)0x00000000)); + Assert.False(NumberBaseHelper.IsZero((nuint)0x00000001)); + Assert.False(NumberBaseHelper.IsZero((nuint)0x7FFFFFFF)); + Assert.False(NumberBaseHelper.IsZero((nuint)0x80000000)); + Assert.False(NumberBaseHelper.IsZero((nuint)0xFFFFFFFF)); + } + } + [Fact] public static void MaxMagnitudeTest() {