119 instantiations of Decimal128
System.Private.CoreLib (119)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal128.cs (117)
84
public static Decimal128 PositiveInfinity => new
Decimal128
(PositiveInfinityValue);
87
public static Decimal128 NegativeInfinity => new
Decimal128
(NegativeInfinityValue);
90
public static Decimal128 NaN => new
Decimal128
(QuietNaNValue);
93
public static Decimal128 NegativeZero => new
Decimal128
(NegativeZeroValue);
96
public static Decimal128 Zero => new
Decimal128
(ZeroValue);
99
public static Decimal128 MinValue => new
Decimal128
(upper: 0xDFFF_ED09_BEAD_87C0, lower: 0x378D_8E63_FFFF_FFFF);
102
public static Decimal128 MaxValue => new
Decimal128
(upper: 0x5FFF_ED09_BEAD_87C0, lower: 0x378D_8E63_FFFF_FFFF);
105
public static Decimal128 Epsilon => new
Decimal128
(upper: 0x0000_0000_0000_0000, lower: 0x0000_0000_0000_0001); // Smallest positive subnormal value, aka 1 * 10^-6176
282
public static Decimal128 DecodeBinary(UInt128 x) => new
Decimal128
(x);
294
public static Decimal128 DecodeDecimal(UInt128 x) => new
Decimal128
(Number.DecodeDecimalIeee754<Decimal128, UInt128>(x));
348
public static Decimal128 operator -(Decimal128 value) => new
Decimal128
(value._upper ^ SignMaskUpper, value._lower);
356
return new
Decimal128
(result);
365
return new
Decimal128
(result);
375
return new
Decimal128
(result);
385
return new
Decimal128
(result);
395
return new
Decimal128
(result);
405
return new
Decimal128
(result);
415
return new
Decimal128
(result);
425
public static explicit operator Decimal128(Int128 value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, Int128>(value));
431
public static explicit operator Decimal128(UInt128 value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, UInt128>(value));
436
public static explicit operator Decimal128(Half value) => new
Decimal128
(Number.ConvertFloatToDecimalIeee754<Half, Decimal128, UInt128>(value));
441
public static explicit operator Decimal128(float value) => new
Decimal128
(Number.ConvertFloatToDecimalIeee754<float, Decimal128, UInt128>(value));
446
public static explicit operator Decimal128(double value) => new
Decimal128
(Number.ConvertFloatToDecimalIeee754<double, Decimal128, UInt128>(value));
635
public static implicit operator Decimal128(byte value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, byte>(value));
641
public static implicit operator Decimal128(sbyte value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, sbyte>(value));
646
public static implicit operator Decimal128(char value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, ushort>(value));
651
public static implicit operator Decimal128(short value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, short>(value));
657
public static implicit operator Decimal128(ushort value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, ushort>(value));
662
public static implicit operator Decimal128(int value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, int>(value));
668
public static implicit operator Decimal128(uint value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, uint>(value));
673
public static implicit operator Decimal128(nint value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, nint>(value));
679
public static implicit operator Decimal128(nuint value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, nuint>(value));
684
public static implicit operator Decimal128(long value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, long>(value));
690
public static implicit operator Decimal128(ulong value) => new
Decimal128
(Number.ConvertIntegerToDecimalIeee754<Decimal128, UInt128, ulong>(value));
695
public static implicit operator Decimal128(decimal value) => new
Decimal128
(Number.ConvertDecimalToDecimalIeee754<Decimal128, UInt128>(value));
798
public static Decimal128 One => new
Decimal128
(OneValue);
801
public static Decimal128 NegativeOne => new
Decimal128
(NegativeOneValue);
804
public static Decimal128 E => new
Decimal128
(EValue);
807
public static Decimal128 Pi => new
Decimal128
(PiValue);
810
public static Decimal128 Tau => new
Decimal128
(TauValue);
817
public static Decimal128 Ceiling(Decimal128 x) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToPositiveInfinity));
828
public static Decimal128 Floor(Decimal128 x) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToNegativeInfinity));
831
public static Decimal128 Round(Decimal128 x) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToEven));
834
public static Decimal128 Round(Decimal128 x, int digits) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), digits, MidpointRounding.ToEven));
837
public static Decimal128 Round(Decimal128 x, MidpointRounding mode) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), 0, mode));
840
public static Decimal128 Round(Decimal128 x, int digits, MidpointRounding mode) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), digits, mode));
843
public static Decimal128 Truncate(Decimal128 x) => new
Decimal128
(Number.RoundDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToZero));
926
public static Decimal128 Acos(Decimal128 x) => new
Decimal128
(Number.AcosDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
929
public static Decimal128 AcosPi(Decimal128 x) => new
Decimal128
(Number.AcosPiDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
932
public static Decimal128 Acosh(Decimal128 x) => new
Decimal128
(Number.AcoshDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
935
public static Decimal128 Asin(Decimal128 x) => new
Decimal128
(Number.AsinDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
938
public static Decimal128 AsinPi(Decimal128 x) => new
Decimal128
(Number.AsinPiDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
941
public static Decimal128 Asinh(Decimal128 x) => new
Decimal128
(Number.AsinhDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
944
public static Decimal128 Atan(Decimal128 x) => new
Decimal128
(Number.AtanDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
947
public static Decimal128 Atan2(Decimal128 y, Decimal128 x) => new
Decimal128
(Number.Atan2DecimalIeee754<Decimal128, UInt128>(new UInt128(y._upper, y._lower), new UInt128(x._upper, x._lower)));
950
public static Decimal128 Atan2Pi(Decimal128 y, Decimal128 x) => new
Decimal128
(Number.Atan2PiDecimalIeee754<Decimal128, UInt128>(new UInt128(y._upper, y._lower), new UInt128(x._upper, x._lower)));
953
public static Decimal128 AtanPi(Decimal128 x) => new
Decimal128
(Number.AtanPiDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
956
public static Decimal128 Atanh(Decimal128 x) => new
Decimal128
(Number.AtanhDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
959
public static Decimal128 BitDecrement(Decimal128 x) => new
Decimal128
(Number.BitDecrementDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
962
public static Decimal128 BitIncrement(Decimal128 x) => new
Decimal128
(Number.BitIncrementDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
965
public static Decimal128 Cbrt(Decimal128 x) => new
Decimal128
(Number.CbrtDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
968
public static Decimal128 Cos(Decimal128 x) => new
Decimal128
(Number.CosDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
971
public static Decimal128 CosPi(Decimal128 x) => new
Decimal128
(Number.CosPiDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
974
public static Decimal128 Cosh(Decimal128 x) => new
Decimal128
(Number.CoshDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
977
public static Decimal128 DegreesToRadians(Decimal128 degrees) => new
Decimal128
(Number.MultiplyByWideConstantDecimalIeee754<Decimal128, UInt128>(new UInt128(degrees._upper, degrees._lower), DegreesToRadiansHead, DegreesToRadiansTail, DegreesToRadiansExponent));
980
public static Decimal128 Exp(Decimal128 x) => new
Decimal128
(Number.ExpDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
983
public static Decimal128 Exp10(Decimal128 x) => new
Decimal128
(Number.Exp10DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
986
public static Decimal128 Exp10M1(Decimal128 x) => new
Decimal128
(Number.Exp10M1DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
989
public static Decimal128 Exp2(Decimal128 x) => new
Decimal128
(Number.Exp2DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
992
public static Decimal128 Exp2M1(Decimal128 x) => new
Decimal128
(Number.Exp2M1DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
995
public static Decimal128 ExpM1(Decimal128 x) => new
Decimal128
(Number.ExpM1DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
998
public static Decimal128 FusedMultiplyAdd(Decimal128 left, Decimal128 right, Decimal128 addend) => new
Decimal128
(Number.FusedMultiplyAddDecimalIeee754<Decimal128, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower), new UInt128(addend._upper, addend._lower)));
1001
public static Decimal128 Hypot(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.HypotDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1004
public static Decimal128 Ieee754Remainder(Decimal128 left, Decimal128 right) => new
Decimal128
(Number.Ieee754RemainderDecimalIeee754<Decimal128, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower)));
1013
public static Decimal128 Log(Decimal128 x) => new
Decimal128
(Number.LogDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1016
public static Decimal128 Log(Decimal128 x, Decimal128 newBase) => new
Decimal128
(Number.LogDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(newBase._upper, newBase._lower)));
1019
public static Decimal128 Log10(Decimal128 x) => new
Decimal128
(Number.Log10DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1022
public static Decimal128 Log10P1(Decimal128 x) => new
Decimal128
(Number.Log10P1DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1025
public static Decimal128 Log2(Decimal128 x) => new
Decimal128
(Number.Log2DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1028
public static Decimal128 Log2P1(Decimal128 x) => new
Decimal128
(Number.Log2P1DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1031
public static Decimal128 LogP1(Decimal128 x) => new
Decimal128
(Number.LogP1DecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1034
public static Decimal128 Pow(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.PowDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1037
public static Decimal128 RadiansToDegrees(Decimal128 radians) => new
Decimal128
(Number.MultiplyByWideConstantDecimalIeee754<Decimal128, UInt128>(new UInt128(radians._upper, radians._lower), RadiansToDegreesHead, RadiansToDegreesTail, RadiansToDegreesExponent));
1046
public static Decimal128 RootN(Decimal128 x, int n) => new
Decimal128
(Number.RootNDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), n));
1049
public static Decimal128 ScaleB(Decimal128 x, int n) => new
Decimal128
(Number.ScaleBDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), n));
1052
public static Decimal128 Sin(Decimal128 x) => new
Decimal128
(Number.SinDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1058
return (new
Decimal128
(sin), new
Decimal128
(cos));
1065
return (new
Decimal128
(sin), new
Decimal128
(cos));
1069
public static Decimal128 SinPi(Decimal128 x) => new
Decimal128
(Number.SinPiDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1072
public static Decimal128 Sinh(Decimal128 x) => new
Decimal128
(Number.SinhDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1075
public static Decimal128 Sqrt(Decimal128 x) => new
Decimal128
(Number.SqrtDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1078
public static Decimal128 Tan(Decimal128 x) => new
Decimal128
(Number.TanDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1081
public static Decimal128 TanPi(Decimal128 x) => new
Decimal128
(Number.TanPiDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1084
public static Decimal128 Tanh(Decimal128 x) => new
Decimal128
(Number.TanhDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1090
public static Decimal128 Quantize(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.QuantizeDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1095
public static Decimal128 GetQuantum(Decimal128 x) => new
Decimal128
(Number.QuantumDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower)));
1106
public static Decimal128 Abs(Decimal128 value) => new
Decimal128
(Number.AbsDecimalIeee754<Decimal128, UInt128>(new UInt128(value._upper, value._lower)));
1177
public static Decimal128 MaxMagnitude(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MaxMagnitudeDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1183
public static Decimal128 MaxMagnitudeNumber(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MaxMagnitudeNumberDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1189
public static Decimal128 MinMagnitude(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MinMagnitudeDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1195
public static Decimal128 MinMagnitudeNumber(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MinMagnitudeNumberDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1238
public static Decimal128 CopySign(Decimal128 value, Decimal128 sign) => new
Decimal128
(Number.CopySignDecimalIeee754<Decimal128, UInt128>(new UInt128(value._upper, value._lower), new UInt128(sign._upper, sign._lower)));
1244
public static Decimal128 Max(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MaxDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1250
public static Decimal128 MaxNative(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MaxNativeDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1256
public static Decimal128 MaxNumber(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MaxNumberDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1262
public static Decimal128 Min(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MinDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1268
public static Decimal128 MinNative(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MinNativeDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1274
public static Decimal128 MinNumber(Decimal128 x, Decimal128 y) => new
Decimal128
(Number.MinNumberDecimalIeee754<Decimal128, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1785
static Decimal128 IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.Construct(UInt128 value) => new
Decimal128
(value);
1845
static bool IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.IsNaN(UInt128 decimalBits) => IsNaN(new
Decimal128
(decimalBits));
1847
static bool IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.IsNegative(UInt128 decimalBits) => IsNegative(new
Decimal128
(decimalBits));
1849
static bool IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.IsFinite(UInt128 decimalBits) => IsFinite(new
Decimal128
(decimalBits));
1851
static bool IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.IsInfinity(UInt128 decimalBits) => IsInfinity(new
Decimal128
(decimalBits));
1853
static bool IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.IsPositiveInfinity(UInt128 decimalBits) => IsPositiveInfinity(new
Decimal128
(decimalBits));
1855
static bool IDecimalIeee754ParseAndFormatInfo<Decimal128, UInt128>.IsNegativeInfinity(UInt128 decimalBits) => IsNegativeInfinity(new
Decimal128
(decimalBits));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal32.cs (1)
706
public static implicit operator Decimal128(Decimal32 value) => new
Decimal128
(Number.ConvertDecimalIeee754<Decimal32, uint, Decimal128, UInt128>(value._value));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal64.cs (1)
699
public static implicit operator Decimal128(Decimal64 value) => new
Decimal128
(Number.ConvertDecimalIeee754<Decimal64, ulong, Decimal128, UInt128>(value._value));
723 references to Decimal128
ILCompiler.ReadyToRun (1)
src\runtime\src\coreclr\tools\Common\JitInterface\WasmLowering.cs (1)
134
/// <see cref="System.UInt128"/>, <see cref="System.Numerics.
Decimal128
"/>,
ILCompiler.RyuJit (1)
src\runtime\src\coreclr\tools\Common\JitInterface\WasmLowering.cs (1)
134
/// <see cref="System.UInt128"/>, <see cref="System.Numerics.
Decimal128
"/>,
System.Private.CoreLib (714)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal128.cs (674)
21
IComparable<
Decimal128
>,
22
IEquatable<
Decimal128
>,
23
IDecimalFloatingPointIeee754<
Decimal128
>,
25
ISpanParsable<
Decimal128
>,
26
IMinMaxValue<
Decimal128
>,
28
IUtf8SpanParsable<
Decimal128
>,
29
IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>
84
public static
Decimal128
PositiveInfinity => new Decimal128(PositiveInfinityValue);
87
public static
Decimal128
NegativeInfinity => new Decimal128(NegativeInfinityValue);
90
public static
Decimal128
NaN => new Decimal128(QuietNaNValue);
93
public static
Decimal128
NegativeZero => new Decimal128(NegativeZeroValue);
96
public static
Decimal128
Zero => new Decimal128(ZeroValue);
99
public static
Decimal128
MinValue => new Decimal128(upper: 0xDFFF_ED09_BEAD_87C0, lower: 0x378D_8E63_FFFF_FFFF);
102
public static
Decimal128
MaxValue => new Decimal128(upper: 0x5FFF_ED09_BEAD_87C0, lower: 0x378D_8E63_FFFF_FFFF);
105
public static
Decimal128
Epsilon => new Decimal128(upper: 0x0000_0000_0000_0000, lower: 0x0000_0000_0000_0001); // Smallest positive subnormal value, aka 1 * 10^-6176
120
/// Parses a <see cref="
Decimal128
"/> from a <see cref="string"/> in the default parse style.
123
/// <returns>The equivalent <see cref="
Decimal128
"/> value representing the input string. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
124
public static
Decimal128
Parse(string s) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null);
127
/// Parses a <see cref="
Decimal128
"/> from a <see cref="string"/> in the given <see cref="NumberStyles"/>.
131
/// <returns>The equivalent <see cref="
Decimal128
"/> value representing the input string. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
132
public static
Decimal128
Parse(string s, NumberStyles style) => Parse(s, style, provider: null);
135
public static
Decimal128
Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider);
138
/// Parses a <see cref="
Decimal128
"/> from a <see cref="string"/> and <see cref="IFormatProvider"/>.
142
/// <returns>The equivalent <see cref="
Decimal128
"/> value representing the input string. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
143
public static
Decimal128
Parse(string s, IFormatProvider? provider) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider);
146
/// Parses a <see cref="
Decimal128
"/> from a <see cref="ReadOnlySpan{Char}"/> and <see cref="IFormatProvider"/>.
151
/// <returns>The equivalent <see cref="
Decimal128
"/> value representing the input string. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
152
public static
Decimal128
Parse(ReadOnlySpan<char> s, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider? provider = null)
155
return Number.ParseDecimalIeee754<char,
Decimal128
, UInt128>(s, style, NumberFormatInfo.GetInstance(provider));
159
/// Parses a <see cref="
Decimal128
"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
164
/// <returns>The equivalent <see cref="
Decimal128
"/> value representing the input string. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
165
public static
Decimal128
Parse(string s, NumberStyles style, IFormatProvider? provider)
175
/// Tries to parse a <see cref="
Decimal128
"/> from a <see cref="string"/> in the default parse style.
178
/// <param name="result">The equivalent <see cref="
Decimal128
"/> value representing the input string if the parse was successful. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
Decimal128
"/> value is returned.</param>
180
public static bool TryParse([NotNullWhen(true)] string? s, out
Decimal128
result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result);
183
/// Tries to parse a <see cref="
Decimal128
"/> from a <see cref="ReadOnlySpan{Char}"/> in the default parse style.
186
/// <param name="result">The equivalent <see cref="
Decimal128
"/> value representing the input string if the parse was successful. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
Decimal128
"/> value is returned.</param>
188
public static bool TryParse(ReadOnlySpan<char> s, out
Decimal128
result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result);
191
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [MaybeNullWhen(false)] out
Decimal128
result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider, out result);
194
/// Tries to parse a <see cref="
Decimal128
"/> from a <see cref="string"/> with the given <see cref="IFormatProvider"/>.
198
/// <param name="result">The equivalent <see cref="
Decimal128
"/> value representing the input string if the parse was successful. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
Decimal128
"/> value is returned.</param>
200
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out
Decimal128
result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider, out result);
203
/// Tries to parse a <see cref="
Decimal128
"/> from a <see cref="ReadOnlySpan{Char}"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
208
/// <param name="result">The equivalent <see cref="
Decimal128
"/> value representing the input string if the parse was successful. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
Decimal128
"/> value is returned.</param>
210
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, [MaybeNullWhen(false)] out
Decimal128
result)
213
return Number.TryParseDecimalIeee754<char,
Decimal128
, UInt128>(s, style, NumberFormatInfo.GetInstance(provider), out result, out _) == Number.ParsingStatus.OK;
217
/// Tries to parse a <see cref="
Decimal128
"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
222
/// <param name="result">The equivalent <see cref="
Decimal128
"/> value representing the input string if the parse was successful. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
Decimal128
"/> value is returned.</param>
224
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, [MaybeNullWhen(false)] out
Decimal128
result)
227
return Number.TryParseDecimalIeee754<char,
Decimal128
, UInt128>(s.AsSpan(), style, NumberFormatInfo.GetInstance(provider), out result, out _) == Number.ParsingStatus.OK;
233
if (value is not
Decimal128
other)
241
public int CompareTo(
Decimal128
other)
245
return Number.CompareDecimalIeee754<
Decimal128
, UInt128>(current, another);
249
public bool Equals(
Decimal128
other)
253
return Number.CompareDecimalIeee754<
Decimal128
, UInt128>(current, another) == 0;
261
return (obj is
Decimal128
other) && Equals(other);
269
return Number.GetDecimalIeee754HashCode<
Decimal128
, UInt128>(new UInt128(_upper, _lower));
276
public static UInt128 EncodeBinary(
Decimal128
x) => new UInt128(x._upper, x._lower);
282
public static
Decimal128
DecodeBinary(UInt128 x) => new Decimal128(x);
288
public static UInt128 EncodeDecimal(
Decimal128
x) => Number.EncodeDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower));
294
public static
Decimal128
DecodeDecimal(UInt128 x) => new Decimal128(Number.DecodeDecimalIeee754<
Decimal128
, UInt128>(x));
301
return Number.FormatDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower), null, NumberFormatInfo.CurrentInfo);
309
return Number.FormatDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower), format, NumberFormatInfo.CurrentInfo);
317
return Number.FormatDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower), null, NumberFormatInfo.GetInstance(provider));
325
return Number.FormatDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower), format, NumberFormatInfo.GetInstance(provider));
331
return Number.TryFormatDecimalIeee754<
Decimal128
, UInt128, char>(new UInt128(_upper, _lower), format, NumberFormatInfo.GetInstance(provider), destination, out charsWritten);
337
return Number.TryFormatDecimalIeee754<
Decimal128
, UInt128, byte>(new UInt128(_upper, _lower), format, NumberFormatInfo.GetInstance(provider), utf8Destination, out bytesWritten);
343
public static
Decimal128
operator +(
Decimal128
value) => value;
348
public static
Decimal128
operator -(
Decimal128
value) => new Decimal128(value._upper ^ SignMaskUpper, value._lower);
353
public static
Decimal128
operator ++(
Decimal128
value)
355
UInt128 result = Number.AddDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower), OneValue);
362
public static
Decimal128
operator --(
Decimal128
value)
364
UInt128 result = Number.SubtractDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower), OneValue);
372
public static
Decimal128
operator +(
Decimal128
left,
Decimal128
right)
374
UInt128 result = Number.AddDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
382
public static
Decimal128
operator -(
Decimal128
left,
Decimal128
right)
384
UInt128 result = Number.SubtractDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
392
public static
Decimal128
operator *(
Decimal128
left,
Decimal128
right)
394
UInt128 result = Number.MultiplyDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
402
public static
Decimal128
operator /(
Decimal128
left,
Decimal128
right)
404
UInt128 result = Number.DivideDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
412
public static
Decimal128
operator %(
Decimal128
left,
Decimal128
right)
414
UInt128 result = Number.RemainderDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
422
/// <summary>Explicitly converts a <see cref="System.Int128" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
424
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
425
public static explicit operator
Decimal128
(Int128 value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, Int128>(value));
427
/// <summary>Explicitly converts a <see cref="System.UInt128" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
429
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
431
public static explicit operator
Decimal128
(UInt128 value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, UInt128>(value));
433
/// <summary>Explicitly converts a <see cref="System.Half" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
435
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
436
public static explicit operator
Decimal128
(Half value) => new Decimal128(Number.ConvertFloatToDecimalIeee754<Half,
Decimal128
, UInt128>(value));
438
/// <summary>Explicitly converts a <see cref="float" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
440
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
441
public static explicit operator
Decimal128
(float value) => new Decimal128(Number.ConvertFloatToDecimalIeee754<float,
Decimal128
, UInt128>(value));
443
/// <summary>Explicitly converts a <see cref="double" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
445
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
446
public static explicit operator
Decimal128
(double value) => new Decimal128(Number.ConvertFloatToDecimalIeee754<double,
Decimal128
, UInt128>(value));
452
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="byte" /> value.</summary>
455
public static explicit operator byte(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, byte>(new UInt128(value._upper, value._lower), isChecked: false);
457
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="byte" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
461
public static explicit operator checked byte(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, byte>(new UInt128(value._upper, value._lower), isChecked: true);
463
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="sbyte" /> value.</summary>
467
public static explicit operator sbyte(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, sbyte>(new UInt128(value._upper, value._lower), isChecked: false);
469
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="sbyte" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
474
public static explicit operator checked sbyte(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, sbyte>(new UInt128(value._upper, value._lower), isChecked: true);
476
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="char" /> value.</summary>
479
public static explicit operator char(
Decimal128
value) => (char)Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, ushort>(new UInt128(value._upper, value._lower), isChecked: false);
481
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="char" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
485
public static explicit operator checked char(
Decimal128
value) => (char)Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, ushort>(new UInt128(value._upper, value._lower), isChecked: true);
487
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="short" /> value.</summary>
490
public static explicit operator short(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, short>(new UInt128(value._upper, value._lower), isChecked: false);
492
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="short" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
496
public static explicit operator checked short(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, short>(new UInt128(value._upper, value._lower), isChecked: true);
498
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="ushort" /> value.</summary>
502
public static explicit operator ushort(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, ushort>(new UInt128(value._upper, value._lower), isChecked: false);
504
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="ushort" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
509
public static explicit operator checked ushort(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, ushort>(new UInt128(value._upper, value._lower), isChecked: true);
511
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="int" /> value.</summary>
514
public static explicit operator int(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, int>(new UInt128(value._upper, value._lower), isChecked: false);
516
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="int" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
520
public static explicit operator checked int(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, int>(new UInt128(value._upper, value._lower), isChecked: true);
522
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="uint" /> value.</summary>
526
public static explicit operator uint(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, uint>(new UInt128(value._upper, value._lower), isChecked: false);
528
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="uint" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
533
public static explicit operator checked uint(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, uint>(new UInt128(value._upper, value._lower), isChecked: true);
535
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.IntPtr" /> value.</summary>
538
public static explicit operator nint(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, nint>(new UInt128(value._upper, value._lower), isChecked: false);
540
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.IntPtr" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
544
public static explicit operator checked nint(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, nint>(new UInt128(value._upper, value._lower), isChecked: true);
546
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.UIntPtr" /> value.</summary>
550
public static explicit operator nuint(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, nuint>(new UInt128(value._upper, value._lower), isChecked: false);
552
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.UIntPtr" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
557
public static explicit operator checked nuint(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, nuint>(new UInt128(value._upper, value._lower), isChecked: true);
559
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="long" /> value.</summary>
562
public static explicit operator long(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, long>(new UInt128(value._upper, value._lower), isChecked: false);
564
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="long" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
568
public static explicit operator checked long(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, long>(new UInt128(value._upper, value._lower), isChecked: true);
570
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="ulong" /> value.</summary>
574
public static explicit operator ulong(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, ulong>(new UInt128(value._upper, value._lower), isChecked: false);
576
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="ulong" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
581
public static explicit operator checked ulong(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, ulong>(new UInt128(value._upper, value._lower), isChecked: true);
583
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.Int128" /> value.</summary>
586
public static explicit operator Int128(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, Int128>(new UInt128(value._upper, value._lower), isChecked: false);
588
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.Int128" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
592
public static explicit operator checked Int128(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, Int128>(new UInt128(value._upper, value._lower), isChecked: true);
594
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.UInt128" /> value.</summary>
598
public static explicit operator UInt128(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, UInt128>(new UInt128(value._upper, value._lower), isChecked: false);
600
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.UInt128" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
605
public static explicit operator checked UInt128(
Decimal128
value) => Number.ConvertDecimalIeee754ToInteger<
Decimal128
, UInt128, UInt128>(new UInt128(value._upper, value._lower), isChecked: true);
607
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.Half" /> value.</summary>
610
public static explicit operator Half(
Decimal128
value) => Number.ConvertDecimalIeee754ToFloat<
Decimal128
, UInt128, Half>(new UInt128(value._upper, value._lower));
612
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="float" /> value.</summary>
615
public static explicit operator float(
Decimal128
value) => Number.ConvertDecimalIeee754ToFloat<
Decimal128
, UInt128, float>(new UInt128(value._upper, value._lower));
617
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="double" /> value.</summary>
620
public static explicit operator double(
Decimal128
value) => Number.ConvertDecimalIeee754ToFloat<
Decimal128
, UInt128, double>(new UInt128(value._upper, value._lower));
622
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="decimal" /> value.</summary>
626
public static explicit operator decimal(
Decimal128
value) => Number.ConvertDecimalIeee754ToDecimal<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
632
/// <summary>Implicitly converts a <see cref="byte" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
634
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
635
public static implicit operator
Decimal128
(byte value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, byte>(value));
637
/// <summary>Implicitly converts a <see cref="sbyte" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
639
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
641
public static implicit operator
Decimal128
(sbyte value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, sbyte>(value));
643
/// <summary>Implicitly converts a <see cref="char" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
645
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
646
public static implicit operator
Decimal128
(char value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, ushort>(value));
648
/// <summary>Implicitly converts a <see cref="short" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
650
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
651
public static implicit operator
Decimal128
(short value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, short>(value));
653
/// <summary>Implicitly converts a <see cref="ushort" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
655
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
657
public static implicit operator
Decimal128
(ushort value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, ushort>(value));
659
/// <summary>Implicitly converts a <see cref="int" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
661
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
662
public static implicit operator
Decimal128
(int value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, int>(value));
664
/// <summary>Implicitly converts a <see cref="uint" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
666
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
668
public static implicit operator
Decimal128
(uint value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, uint>(value));
670
/// <summary>Implicitly converts a <see cref="System.IntPtr" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
672
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
673
public static implicit operator
Decimal128
(nint value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, nint>(value));
675
/// <summary>Implicitly converts a <see cref="System.UIntPtr" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
677
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
679
public static implicit operator
Decimal128
(nuint value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, nuint>(value));
681
/// <summary>Implicitly converts a <see cref="long" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
683
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
684
public static implicit operator
Decimal128
(long value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, long>(value));
686
/// <summary>Implicitly converts a <see cref="ulong" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
688
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
690
public static implicit operator
Decimal128
(ulong value) => new Decimal128(Number.ConvertIntegerToDecimalIeee754<
Decimal128
, UInt128, ulong>(value));
692
/// <summary>Implicitly converts a <see cref="decimal" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
694
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
695
public static implicit operator
Decimal128
(decimal value) => new Decimal128(Number.ConvertDecimalToDecimalIeee754<
Decimal128
, UInt128>(value));
701
public static bool operator ==(
Decimal128
left,
Decimal128
right)
703
return Number.EqualsDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
710
public static bool operator !=(
Decimal128
left,
Decimal128
right)
719
public static bool operator <(
Decimal128
left,
Decimal128
right)
721
return Number.LessThanDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
728
public static bool operator >(
Decimal128
left,
Decimal128
right)
730
return Number.GreaterThanDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
737
public static bool operator <=(
Decimal128
left,
Decimal128
right)
739
return Number.LessThanOrEqualDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
746
public static bool operator >=(
Decimal128
left,
Decimal128
right)
748
return Number.GreaterThanOrEqualDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower));
756
public static bool TryParsePartial([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out
Decimal128
result, out int charsConsumed)
759
return Number.TryParseDecimalIeee754<char,
Decimal128
, UInt128>(s.AsSpan(), style | Number.AllowTrailingInvalidCharacters, NumberFormatInfo.GetInstance(provider), out result, out charsConsumed) == Number.ParsingStatus.OK;
763
public static bool TryParsePartial(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out
Decimal128
result, out int charsConsumed)
766
return Number.TryParseDecimalIeee754<char,
Decimal128
, UInt128>(s, style | Number.AllowTrailingInvalidCharacters, NumberFormatInfo.GetInstance(provider), out result, out charsConsumed) == Number.ParsingStatus.OK;
770
public static bool TryParsePartial(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out
Decimal128
result, out int bytesConsumed)
773
return Number.TryParseDecimalIeee754<byte,
Decimal128
, UInt128>(utf8Text, style | Number.AllowTrailingInvalidCharacters, NumberFormatInfo.GetInstance(provider), out result, out bytesConsumed) == Number.ParsingStatus.OK;
777
/// Tries to parse a <see cref="
Decimal128
"/> from a <see cref="ReadOnlySpan{Byte}"/> containing UTF-8 text in the default parse style.
780
/// <param name="result">The equivalent <see cref="
Decimal128
"/> value representing the input if the parse was successful. If the input exceeds Decimal128's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
Decimal128
"/> value is returned.</param>
782
public static bool TryParse(ReadOnlySpan<byte> utf8Text, out
Decimal128
result) => TryParse(utf8Text, provider: null, out result);
785
public static
Decimal128
Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider? provider = null)
788
return Number.ParseDecimalIeee754<byte,
Decimal128
, UInt128>(utf8Text, style, NumberFormatInfo.GetInstance(provider));
792
public static
Decimal128
Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider);
795
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out
Decimal128
result) => Number.TryParseDecimalIeee754<byte,
Decimal128
, UInt128>(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider), out result, out _) == Number.ParsingStatus.OK;
798
public static
Decimal128
One => new Decimal128(OneValue);
801
public static
Decimal128
NegativeOne => new Decimal128(NegativeOneValue);
804
public static
Decimal128
E => new Decimal128(EValue);
807
public static
Decimal128
Pi => new Decimal128(PiValue);
810
public static
Decimal128
Tau => new Decimal128(TauValue);
817
public static
Decimal128
Ceiling(
Decimal128
x) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToPositiveInfinity));
820
public static TInteger ConvertToInteger<TInteger>(
Decimal128
value)
824
public static TInteger ConvertToIntegerNative<TInteger>(
Decimal128
value)
828
public static
Decimal128
Floor(
Decimal128
x) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToNegativeInfinity));
831
public static
Decimal128
Round(
Decimal128
x) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToEven));
834
public static
Decimal128
Round(
Decimal128
x, int digits) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), digits, MidpointRounding.ToEven));
837
public static
Decimal128
Round(
Decimal128
x, MidpointRounding mode) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), 0, mode));
840
public static
Decimal128
Round(
Decimal128
x, int digits, MidpointRounding mode) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), digits, mode));
843
public static
Decimal128
Truncate(
Decimal128
x) => new Decimal128(Number.RoundDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), 0, MidpointRounding.ToZero));
846
int IFloatingPoint<
Decimal128
>.GetExponentByteCount() => sizeof(int);
849
int IFloatingPoint<
Decimal128
>.GetExponentShortestBitLength()
851
int exponent = Number.UnpackDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower)).UnbiasedExponent;
864
int IFloatingPoint<
Decimal128
>.GetSignificandBitLength() => 113;
867
int IFloatingPoint<
Decimal128
>.GetSignificandByteCount() => Unsafe.SizeOf<UInt128>();
870
bool IFloatingPoint<
Decimal128
>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten)
872
if (BinaryPrimitives.TryWriteInt32BigEndian(destination, Number.UnpackDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower)).UnbiasedExponent))
883
bool IFloatingPoint<
Decimal128
>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten)
885
if (BinaryPrimitives.TryWriteInt32LittleEndian(destination, Number.UnpackDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower)).UnbiasedExponent))
896
bool IFloatingPoint<
Decimal128
>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten)
898
if (BinaryPrimitives.TryWriteUInt128BigEndian(destination, Number.UnpackDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower)).Significand))
909
bool IFloatingPoint<
Decimal128
>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten)
911
if (BinaryPrimitives.TryWriteUInt128LittleEndian(destination, Number.UnpackDecimalIeee754<
Decimal128
, UInt128>(new UInt128(_upper, _lower)).Significand))
926
public static
Decimal128
Acos(
Decimal128
x) => new Decimal128(Number.AcosDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
929
public static
Decimal128
AcosPi(
Decimal128
x) => new Decimal128(Number.AcosPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
932
public static
Decimal128
Acosh(
Decimal128
x) => new Decimal128(Number.AcoshDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
935
public static
Decimal128
Asin(
Decimal128
x) => new Decimal128(Number.AsinDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
938
public static
Decimal128
AsinPi(
Decimal128
x) => new Decimal128(Number.AsinPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
941
public static
Decimal128
Asinh(
Decimal128
x) => new Decimal128(Number.AsinhDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
944
public static
Decimal128
Atan(
Decimal128
x) => new Decimal128(Number.AtanDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
947
public static
Decimal128
Atan2(
Decimal128
y,
Decimal128
x) => new Decimal128(Number.Atan2DecimalIeee754<
Decimal128
, UInt128>(new UInt128(y._upper, y._lower), new UInt128(x._upper, x._lower)));
950
public static
Decimal128
Atan2Pi(
Decimal128
y,
Decimal128
x) => new Decimal128(Number.Atan2PiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(y._upper, y._lower), new UInt128(x._upper, x._lower)));
953
public static
Decimal128
AtanPi(
Decimal128
x) => new Decimal128(Number.AtanPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
956
public static
Decimal128
Atanh(
Decimal128
x) => new Decimal128(Number.AtanhDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
959
public static
Decimal128
BitDecrement(
Decimal128
x) => new Decimal128(Number.BitDecrementDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
962
public static
Decimal128
BitIncrement(
Decimal128
x) => new Decimal128(Number.BitIncrementDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
965
public static
Decimal128
Cbrt(
Decimal128
x) => new Decimal128(Number.CbrtDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
968
public static
Decimal128
Cos(
Decimal128
x) => new Decimal128(Number.CosDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
971
public static
Decimal128
CosPi(
Decimal128
x) => new Decimal128(Number.CosPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
974
public static
Decimal128
Cosh(
Decimal128
x) => new Decimal128(Number.CoshDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
977
public static
Decimal128
DegreesToRadians(
Decimal128
degrees) => new Decimal128(Number.MultiplyByWideConstantDecimalIeee754<
Decimal128
, UInt128>(new UInt128(degrees._upper, degrees._lower), DegreesToRadiansHead, DegreesToRadiansTail, DegreesToRadiansExponent));
980
public static
Decimal128
Exp(
Decimal128
x) => new Decimal128(Number.ExpDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
983
public static
Decimal128
Exp10(
Decimal128
x) => new Decimal128(Number.Exp10DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
986
public static
Decimal128
Exp10M1(
Decimal128
x) => new Decimal128(Number.Exp10M1DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
989
public static
Decimal128
Exp2(
Decimal128
x) => new Decimal128(Number.Exp2DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
992
public static
Decimal128
Exp2M1(
Decimal128
x) => new Decimal128(Number.Exp2M1DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
995
public static
Decimal128
ExpM1(
Decimal128
x) => new Decimal128(Number.ExpM1DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
998
public static
Decimal128
FusedMultiplyAdd(
Decimal128
left,
Decimal128
right,
Decimal128
addend) => new Decimal128(Number.FusedMultiplyAddDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower), new UInt128(addend._upper, addend._lower)));
1001
public static
Decimal128
Hypot(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.HypotDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1004
public static
Decimal128
Ieee754Remainder(
Decimal128
left,
Decimal128
right) => new Decimal128(Number.Ieee754RemainderDecimalIeee754<
Decimal128
, UInt128>(new UInt128(left._upper, left._lower), new UInt128(right._upper, right._lower)));
1007
public static int ILogB(
Decimal128
x) => Number.ILogBDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower));
1010
public static
Decimal128
Lerp(
Decimal128
value1,
Decimal128
value2,
Decimal128
amount) => MultiplyAddEstimate(value1, One - amount, value2 * amount);
1013
public static
Decimal128
Log(
Decimal128
x) => new Decimal128(Number.LogDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1016
public static
Decimal128
Log(
Decimal128
x,
Decimal128
newBase) => new Decimal128(Number.LogDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(newBase._upper, newBase._lower)));
1019
public static
Decimal128
Log10(
Decimal128
x) => new Decimal128(Number.Log10DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1022
public static
Decimal128
Log10P1(
Decimal128
x) => new Decimal128(Number.Log10P1DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1025
public static
Decimal128
Log2(
Decimal128
x) => new Decimal128(Number.Log2DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1028
public static
Decimal128
Log2P1(
Decimal128
x) => new Decimal128(Number.Log2P1DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1031
public static
Decimal128
LogP1(
Decimal128
x) => new Decimal128(Number.LogP1DecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1034
public static
Decimal128
Pow(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.PowDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1037
public static
Decimal128
RadiansToDegrees(
Decimal128
radians) => new Decimal128(Number.MultiplyByWideConstantDecimalIeee754<
Decimal128
, UInt128>(new UInt128(radians._upper, radians._lower), RadiansToDegreesHead, RadiansToDegreesTail, RadiansToDegreesExponent));
1040
public static
Decimal128
ReciprocalEstimate(
Decimal128
x) => One / x;
1043
public static
Decimal128
ReciprocalSqrtEstimate(
Decimal128
x) => One / Sqrt(x);
1046
public static
Decimal128
RootN(
Decimal128
x, int n) => new Decimal128(Number.RootNDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), n));
1049
public static
Decimal128
ScaleB(
Decimal128
x, int n) => new Decimal128(Number.ScaleBDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), n));
1052
public static
Decimal128
Sin(
Decimal128
x) => new Decimal128(Number.SinDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1055
public static (
Decimal128
Sin,
Decimal128
Cos) SinCos(
Decimal128
x)
1057
(UInt128 sin, UInt128 cos) = Number.SinCosDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower));
1062
public static (
Decimal128
SinPi,
Decimal128
CosPi) SinCosPi(
Decimal128
x)
1064
(UInt128 sin, UInt128 cos) = Number.SinCosPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower));
1069
public static
Decimal128
SinPi(
Decimal128
x) => new Decimal128(Number.SinPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1072
public static
Decimal128
Sinh(
Decimal128
x) => new Decimal128(Number.SinhDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1075
public static
Decimal128
Sqrt(
Decimal128
x) => new Decimal128(Number.SqrtDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1078
public static
Decimal128
Tan(
Decimal128
x) => new Decimal128(Number.TanDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1081
public static
Decimal128
TanPi(
Decimal128
x) => new Decimal128(Number.TanPiDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1084
public static
Decimal128
Tanh(
Decimal128
x) => new Decimal128(Number.TanhDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1090
public static
Decimal128
Quantize(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.QuantizeDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1095
public static
Decimal128
GetQuantum(
Decimal128
x) => new Decimal128(Number.QuantumDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower)));
1101
public static bool HaveSameQuantum(
Decimal128
x,
Decimal128
y) => Number.SameQuantumDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower));
1106
public static
Decimal128
Abs(
Decimal128
value) => new Decimal128(Number.AbsDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower)));
1111
public static bool IsFinite(
Decimal128
value) => (value._upper & InfinityMaskUpper) != InfinityMaskUpper;
1116
public static bool IsInfinity(
Decimal128
value) => (value._upper & NaNMaskUpper) == InfinityMaskUpper;
1121
public static bool IsNaN(
Decimal128
value) => (value._upper & NaNMaskUpper) == NaNMaskUpper;
1126
public static bool IsNegative(
Decimal128
value) => (value._upper & SignMaskUpper) != 0;
1131
public static bool IsNegativeInfinity(
Decimal128
value) => (value._upper & (SignMaskUpper | NaNMaskUpper)) == NegativeInfinityValue.Upper;
1136
public static bool IsPositive(
Decimal128
value) => (value._upper & SignMaskUpper) == 0;
1141
public static bool IsPositiveInfinity(
Decimal128
value) => (value._upper & (SignMaskUpper | NaNMaskUpper)) == PositiveInfinityValue.Upper;
1146
public static bool IsRealNumber(
Decimal128
value) => !IsNaN(value);
1151
public static bool IsInteger(
Decimal128
value) => Number.IsIntegerDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1156
public static bool IsEvenInteger(
Decimal128
value) => Number.IsEvenIntegerDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1161
public static bool IsOddInteger(
Decimal128
value) => Number.IsOddIntegerDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1166
public static bool IsNormal(
Decimal128
value) => Number.IsNormalDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1171
public static bool IsSubnormal(
Decimal128
value) => Number.IsSubnormalDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1177
public static
Decimal128
MaxMagnitude(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MaxMagnitudeDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1183
public static
Decimal128
MaxMagnitudeNumber(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MaxMagnitudeNumberDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1189
public static
Decimal128
MinMagnitude(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MinMagnitudeDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1195
public static
Decimal128
MinMagnitudeNumber(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MinMagnitudeNumberDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1202
public static
Decimal128
MultiplyAddEstimate(
Decimal128
left,
Decimal128
right,
Decimal128
addend) => (left * right) + addend;
1210
public static
Decimal128
Clamp(
Decimal128
value,
Decimal128
min,
Decimal128
max)
1225
public static
Decimal128
ClampNative(
Decimal128
value,
Decimal128
min,
Decimal128
max)
1238
public static
Decimal128
CopySign(
Decimal128
value,
Decimal128
sign) => new Decimal128(Number.CopySignDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower), new UInt128(sign._upper, sign._lower)));
1244
public static
Decimal128
Max(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MaxDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1250
public static
Decimal128
MaxNative(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MaxNativeDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1256
public static
Decimal128
MaxNumber(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MaxNumberDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1262
public static
Decimal128
Min(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MinDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1268
public static
Decimal128
MinNative(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MinNativeDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1274
public static
Decimal128
MinNumber(
Decimal128
x,
Decimal128
y) => new Decimal128(Number.MinNumberDecimalIeee754<
Decimal128
, UInt128>(new UInt128(x._upper, x._lower), new UInt128(y._upper, y._lower)));
1280
public static int Sign(
Decimal128
value) => Number.SignDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1283
static int INumberBase<
Decimal128
>.Radix => 10;
1286
static bool INumberBase<
Decimal128
>.IsCanonical(
Decimal128
value) => Number.IsCanonicalDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower), nanReservedMask: new UInt128(0x01FF_C000_0000_0000, 0x0000_0000_0000_0000), nanPayloadMask: NaNPayloadMask, maxNaNPayload: new UInt128(0x0000_314D_C644_8D93, 0x38C1_5B09_FFFF_FFFF));
1289
static bool INumberBase<
Decimal128
>.IsComplexNumber(
Decimal128
value) => false;
1292
static bool INumberBase<
Decimal128
>.IsImaginaryNumber(
Decimal128
value) => false;
1295
static bool INumberBase<
Decimal128
>.IsZero(
Decimal128
value) => Number.IsZeroDecimalIeee754<
Decimal128
, UInt128>(new UInt128(value._upper, value._lower));
1298
static
Decimal128
IAdditiveIdentity<
Decimal128
,
Decimal128
>.AdditiveIdentity => Zero;
1301
static
Decimal128
IMultiplicativeIdentity<
Decimal128
,
Decimal128
>.MultiplicativeIdentity => One;
1305
public static
Decimal128
CreateChecked<TOther>(TOther value)
1308
Decimal128
result;
1310
if (typeof(TOther) == typeof(
Decimal128
))
1312
result = (
Decimal128
)(object)value;
1324
public static
Decimal128
CreateSaturating<TOther>(TOther value)
1327
Decimal128
result;
1329
if (typeof(TOther) == typeof(
Decimal128
))
1331
result = (
Decimal128
)(object)value;
1343
public static
Decimal128
CreateTruncating<TOther>(TOther value)
1346
Decimal128
result;
1348
if (typeof(TOther) == typeof(
Decimal128
))
1350
result = (
Decimal128
)(object)value;
1362
static bool INumberBase<
Decimal128
>.TryConvertFromChecked<TOther>(TOther value, out
Decimal128
result) => TryConvertFrom(value, out result);
1366
static bool INumberBase<
Decimal128
>.TryConvertFromSaturating<TOther>(TOther value, out
Decimal128
result) => TryConvertFrom(value, out result);
1370
static bool INumberBase<
Decimal128
>.TryConvertFromTruncating<TOther>(TOther value, out
Decimal128
result) => TryConvertFrom(value, out result);
1373
private static bool TryConvertFrom<TOther>(TOther value, out
Decimal128
result)
1427
result = (
Decimal128
)(Int128)(object)value;
1432
result = (
Decimal128
)(UInt128)(object)value;
1447
result = (
Decimal128
)(Half)(object)value;
1452
result = (
Decimal128
)(float)(object)value;
1457
result = (
Decimal128
)(double)(object)value;
1484
static bool INumberBase<
Decimal128
>.TryConvertToChecked<TOther>(
Decimal128
value, [MaybeNullWhen(false)] out TOther result)
1607
static bool INumberBase<
Decimal128
>.TryConvertToSaturating<TOther>(
Decimal128
value, [MaybeNullWhen(false)] out TOther result) => TryConvertTo(value, out result);
1611
static bool INumberBase<
Decimal128
>.TryConvertToTruncating<TOther>(
Decimal128
value, [MaybeNullWhen(false)] out TOther result) => TryConvertTo(value, out result);
1614
private static bool TryConvertTo<TOther>(
Decimal128
value, [MaybeNullWhen(false)] out TOther result)
1704
decimal actualResult = (value > (
Decimal128
)decimal.MaxValue) ? decimal.MaxValue :
1705
(value < (
Decimal128
)decimal.MinValue) ? decimal.MinValue :
1767
static string IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.ToDecStr(UInt128 significand)
1772
static unsafe UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.NumberToSignificand(ref Number.NumberBuffer number, int digits)
1785
static
Decimal128
IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.Construct(UInt128 value) => new Decimal128(value);
1787
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.ConvertToExponent(UInt128 value) => (int)value;
1789
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.Power10(int exponent) => UInt128Powers10[exponent];
1791
static (UInt128 Quotient, UInt128 Remainder) IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.DivRemPow10(UInt128 value, int exponent)
1797
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.CountDigits(UInt128 significand) => FormattingHelpers.CountDigits(significand);
1799
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.Precision => Precision;
1801
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.BufferLength => Number.Decimal128NumberBufferLength;
1803
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.MaxExponent => MaxExponent;
1805
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.MinExponent => MinExponent;
1807
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.MaxAdjustedExponent => MaxExponent - Precision + 1;
1809
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.MinAdjustedExponent => MinExponent - Precision + 1;
1811
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.PositiveInfinity => PositiveInfinityValue;
1813
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.NegativeInfinity => NegativeInfinityValue;
1815
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.Zero => ZeroValue;
1817
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.NaN => QuietNaNValue;
1819
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.MostSignificantBitOfSignificandMask => new UInt128(0x0002_0000_0000_0000, 0);
1821
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.NaNMask => new UInt128(NaNMaskUpper, 0);
1823
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.SNaNMask => new UInt128(SNaNMaskUpper, 0);
1825
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.NaNPayloadMask => NaNPayloadMask;
1827
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.SignMask => new UInt128(SignMaskUpper, 0);
1829
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.G0G1Mask => new UInt128(0x6000_0000_0000_0000, 0);
1831
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.ExponentBias => ExponentBias;
1833
static int IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.NumberBitsSignificand => 110;
1835
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.G0ToGwPlus1ExponentMask => new UInt128(0x7FFE_0000_0000_0000, 0);
1837
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.G2ToGwPlus3ExponentMask => new UInt128(0x1FFF_8000_0000_0000, 0);
1839
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.GwPlus2ToGwPlus4SignificandMask => new UInt128(0x0001_FFFF_FFFF_FFFF, 0xFFFF_FFFF_FFFF_FFFF);
1841
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.GwPlus4SignificandMask => new UInt128(0x0000_7FFF_FFFF_FFFF, 0xFFFF_FFFF_FFFF_FFFF);
1843
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.MaxSignificand => new UInt128(upper: 0x0001_ED09_BEAD_87C0, lower: 0x378D_8E63_FFFF_FFFF); // 9_999_999_999_999_999_999_999_999_999_999_999;
1845
static bool IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.IsNaN(UInt128 decimalBits) => IsNaN(new Decimal128(decimalBits));
1847
static bool IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.IsNegative(UInt128 decimalBits) => IsNegative(new Decimal128(decimalBits));
1849
static bool IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.IsFinite(UInt128 decimalBits) => IsFinite(new Decimal128(decimalBits));
1851
static bool IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.IsInfinity(UInt128 decimalBits) => IsInfinity(new Decimal128(decimalBits));
1853
static bool IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.IsPositiveInfinity(UInt128 decimalBits) => IsPositiveInfinity(new Decimal128(decimalBits));
1855
static bool IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.IsNegativeInfinity(UInt128 decimalBits) => IsNegativeInfinity(new Decimal128(decimalBits));
1857
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.EncodeExponentToG0ThroughGwPlus1(uint biasedExponent)
1862
static UInt128 IDecimalIeee754ParseAndFormatInfo<
Decimal128
, UInt128>.EncodeExponentToG2ThroughGwPlus3(uint biasedExponent)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal32.cs (17)
473
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.Numerics.Decimal32" /> value.</summary>
476
public static explicit operator Decimal32(
Decimal128
value) => new Decimal32(Number.ConvertDecimalIeee754<
Decimal128
, UInt128, Decimal32, uint>(new UInt128(value._upper, value._lower)));
703
/// <summary>Implicitly converts a <see cref="System.Numerics.Decimal32" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
705
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
706
public static implicit operator
Decimal128
(Decimal32 value) => new Decimal128(Number.ConvertDecimalIeee754<Decimal32, uint,
Decimal128
, UInt128>(value._value));
1481
else if (typeof(TOther) == typeof(
Decimal128
))
1483
result = (Decimal32)(
Decimal128
)(object)value;
1604
else if (typeof(TOther) == typeof(
Decimal128
))
1606
result = (TOther)(object)(
Decimal128
)value;
1719
Decimal128
wide = (
Decimal128
)value;
1720
decimal actualResult = (wide > (
Decimal128
)decimal.MaxValue) ? decimal.MaxValue :
1721
(wide < (
Decimal128
)decimal.MinValue) ? decimal.MinValue :
1731
else if (typeof(TOther) == typeof(
Decimal128
))
1733
result = (TOther)(object)(
Decimal128
)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal64.cs (17)
460
/// <summary>Explicitly converts a <see cref="System.Numerics.
Decimal128
" /> value to its nearest representable <see cref="System.Numerics.Decimal64" /> value.</summary>
463
public static explicit operator Decimal64(
Decimal128
value) => new Decimal64(Number.ConvertDecimalIeee754<
Decimal128
, UInt128, Decimal64, ulong>(new UInt128(value._upper, value._lower)));
696
/// <summary>Implicitly converts a <see cref="System.Numerics.Decimal64" /> value to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</summary>
698
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Numerics.
Decimal128
" /> value.</returns>
699
public static implicit operator
Decimal128
(Decimal64 value) => new Decimal128(Number.ConvertDecimalIeee754<Decimal64, ulong,
Decimal128
, UInt128>(value._value));
1474
else if (typeof(TOther) == typeof(
Decimal128
))
1476
result = (Decimal64)(
Decimal128
)(object)value;
1597
else if (typeof(TOther) == typeof(
Decimal128
))
1599
result = (TOther)(object)(
Decimal128
)value;
1712
Decimal128
wide = (
Decimal128
)value;
1713
decimal actualResult = (wide > (
Decimal128
)decimal.MaxValue) ? decimal.MaxValue :
1714
(wide < (
Decimal128
)decimal.MinValue) ? decimal.MinValue :
1724
else if (typeof(TOther) == typeof(
Decimal128
))
1726
result = (TOther)(object)(
Decimal128
)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\TotalOrderIeee754Comparer.cs (6)
82
else if (typeof(T) == typeof(
Decimal128
))
84
Decimal128
xValue = (
Decimal128
)(object)x!;
85
Decimal128
yValue = (
Decimal128
)(object)y!;
86
return CompareDecimal<
Decimal128
, UInt128>(new UInt128(xValue._upper, xValue._lower), new UInt128(yValue._upper, yValue._lower));
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
378
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.
Decimal128
))]
System.Text.Json (6)
System\Text\Json\Nodes\JsonValueOfT.cs (1)
109
type == typeof(System.Numerics.Decimal64) || type == typeof(System.Numerics.
Decimal128
))
System\Text\Json\Serialization\Converters\Value\JsonPrimitiveConverter.cs (1)
40
typeof(T) == typeof(System.Numerics.Decimal64) || typeof(T) == typeof(System.Numerics.
Decimal128
)));
System\Text\Json\Serialization\Metadata\JsonMetadataServices.Converters.cs (3)
201
/// Returns a <see cref="JsonConverter{T}"/> instance that converts <see cref="System.Numerics.
Decimal128
"/> values.
204
public static JsonConverter<System.Numerics.
Decimal128
> Decimal128Converter =>
205
field ??= new Ieee754FloatingPointConverter<System.Numerics.
Decimal128
>(NumericType.Decimal128);
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (1)
732
potentialNumberType == typeof(System.Numerics.
Decimal128
) ||