102 instantiations of BigInteger
Microsoft.CodeAnalysis (2)
Microsoft.Gen.Logging.Generated.Tests (1)
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (1)
Microsoft.NET.Sdk.StaticWebAssets.Tasks (2)
NuGet.Packaging (3)
System.Formats.Asn1 (2)
System.Formats.Cbor (1)
System.Runtime.Numerics (82)
System\Numerics\BigInteger.cs (76)
59private static readonly BigInteger s_int32MinValue = new(-1, [UInt32HighBit]);
60private static readonly BigInteger s_one = new(1);
61private static readonly BigInteger s_zero = new(0);
62private static readonly BigInteger s_minusOne = new(-1);
884return new BigInteger((int)NumericsHelpers.Abs(value._sign), value._bits);
945return new BigInteger(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
965remainder = new(rest, dividend._sign < 0);
966BigInteger result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
1062: new BigInteger(+1, right._bits);
1070: new BigInteger(+1, left._bits);
1109result = new BigInteger(bits, negative: false);
1169result = new BigInteger(bits, value._sign < 0 && !exponent.IsEven);
1217result = new BigInteger(bits, value._sign < 0 && (exponent & 1) != 0);
1226result = new BigInteger(bits, value._sign < 0 && (exponent & 1) != 0);
1906result = new BigInteger(bits, leftSign < 0);
1917result = new BigInteger(bits, leftSign < 0);
1928result = new BigInteger(bits, leftSign < 0);
1939result = new BigInteger(bits, leftSign < 0);
1975result = new BigInteger(bits, leftSign >= 0);
1986result = new BigInteger(bits, leftSign < 0);
1995result = new BigInteger(bits, leftSign >= 0);
2006result = new BigInteger(bits, leftSign < 0);
2376public static explicit operator BigInteger(decimal value) => new BigInteger(value);
2378public static explicit operator BigInteger(double value) => new BigInteger(value);
2383public static explicit operator BigInteger(Half value) => new BigInteger((float)value);
2388public static explicit operator BigInteger(BFloat16 value) => new BigInteger((float)value);
2403public static explicit operator BigInteger(float value) => new BigInteger(value);
2409public static implicit operator BigInteger(byte value) => new BigInteger(value);
2414public static implicit operator BigInteger(char value) => new BigInteger(value);
2416public static implicit operator BigInteger(short value) => new BigInteger(value);
2418public static implicit operator BigInteger(int value) => new BigInteger(value);
2420public static implicit operator BigInteger(long value) => new BigInteger(value);
2487return new BigInteger(sign, bits);
2493public static implicit operator BigInteger(nint value) => new BigInteger(value);
2496public static implicit operator BigInteger(sbyte value) => new BigInteger(value);
2499public static implicit operator BigInteger(ushort value) => new BigInteger(value);
2502public static implicit operator BigInteger(uint value) => new BigInteger(value);
2505public static implicit operator BigInteger(ulong value) => new BigInteger(value);
2556return new BigInteger(sign, bits);
2563public static implicit operator BigInteger(nuint value) => value <= int.MaxValue ? new BigInteger((int)value, null) : new BigInteger(+1, [value]);
2642BigInteger result = new(z);
2704return new BigInteger(value._sign, z);
2727return new BigInteger(value >= 0 ? (int)r : -(int)r, null);
2740return new BigInteger(value > 0 ? 1 : -1, rgu);
2772return new BigInteger(value._sign >> smallShift, null);
2783return new BigInteger(value._sign >> 31, null);
2804BigInteger result = new(zd, neg);
2829result = new BigInteger(bits, negative: true);
2838result = new BigInteger(bits, negative: false);
2845public static BigInteger operator -(BigInteger value) => new BigInteger(-value._sign, value._bits);
2864result = new BigInteger(bits, negative: false);
2872result = new BigInteger(bits, negative: true);
2893result = new BigInteger(bits, negative: false);
2902result = new BigInteger(bits, negative: true);
2943result = new BigInteger(bits, (leftSign < 0) ^ (rightSign < 0));
2954result = new BigInteger(bits, (leftSign < 0) ^ (rightSign < 0));
2963result = new BigInteger(bits, (leftSign < 0) ^ (rightSign < 0));
2974result = new BigInteger(bits, (leftSign < 0) ^ (rightSign < 0));
3008BigInteger result = new BigInteger(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3027BigInteger result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3070BigInteger result = new(bits, dividend._sign < 0);
3354? new BigInteger((int)rs)
3355: new BigInteger(rs);
3375? new BigInteger((int)rs)
3376: new BigInteger(rs);
3569BigInteger result = new(zd, negative);
3631BigInteger result = new(zd, negative);
3667value = new BigInteger(source, isUnsigned, isBigEndian: true);
3674value = new BigInteger(source, isUnsigned, isBigEndian: false);
5319return new BigInteger((nint)value._sign >>> smallShift);
5360return new BigInteger(nint.MinValue >>> smallShift);
5365return new BigInteger(smallShift == 0 ? -1 : +1, rgu);
5408result = new BigInteger(zd, true);
5412result = new BigInteger(zd, false);
5420return new BigInteger(value._sign >> 31, null);
System.Security.Cryptography (4)
System.Security.Cryptography.Cose (1)
System.Security.Cryptography.Pkcs (2)
System.Security.Cryptography.Xml (1)
695 references to BigInteger
Microsoft.AspNetCore.Http.Extensions (4)
Microsoft.AspNetCore.Mvc.Abstractions (4)
Microsoft.AspNetCore.OpenApi (4)
Microsoft.CodeAnalysis (25)
RealParser.cs (22)
60private static readonly BigInteger s_bigZero = BigInteger.Zero;
61private static readonly BigInteger s_bigOne = BigInteger.One;
62private static readonly BigInteger s_bigTwo = new BigInteger(2);
63private static readonly BigInteger s_bigTen = new BigInteger(10);
415BigInteger integerValue = AccumulateDecimalDigitsIntoBigInteger(data, integerFirstIndex, integerLastIndex);
465BigInteger fractionalNumerator = AccumulateDecimalDigitsIntoBigInteger(data, fractionalFirstIndex, fractionalLastIndex);
468BigInteger fractionalDenominator = s_bigOne;
531BigInteger fractionalRemainder;
532BigInteger bigFractionalMantissa = BigInteger.DivRem(fractionalNumerator, fractionalDenominator, out fractionalRemainder);
621private static BigInteger AccumulateDecimalDigitsIntoBigInteger(DecimalFloatingPointString data, uint integer_first_index, uint integer_last_index)
625return BigInteger.Parse(valueString);
661private static uint CountSignificantBits(BigInteger data, out byte[] dataBytes)
682private static uint CountSignificantBits(BigInteger data)
750private static void ShiftLeft(ref BigInteger number, uint shift)
752var powerOfTwo = BigInteger.Pow(s_bigTwo, (int)shift);
761private static void MultiplyByPowerOfTen(ref BigInteger number, uint power)
763var powerOfTen = BigInteger.Pow(s_bigTen, (int)power);
Microsoft.Gen.Logging.Generated.Tests (1)
Microsoft.Gen.Logging.Unit.Tests (3)
Microsoft.ML.Parquet (2)
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (4)
Microsoft.NET.Sdk.StaticWebAssets.Tasks (8)
netstandard (1)
NuGet.Packaging (12)
PresentationBuildTasks (3)
System.Data.Common (51)
System\Data\Common\BigIntegerStorage.cs (23)
13private BigInteger[] _values = default!; // Late-initialized
16base(column, typeof(BigInteger), BigInteger.Zero, StorageType.BigInteger)
27BigInteger valueNo1 = _values[recordNo1];
28BigInteger valueNo2 = _values[recordNo2];
52BigInteger valueNo1 = _values[recordNo];
58return valueNo1.CompareTo((BigInteger)value);
62internal static BigInteger ConvertToBigInteger(object value, IFormatProvider formatProvider)
64if (value.GetType() == typeof(BigInteger)) { return (BigInteger)value; }
65else if (value.GetType() == typeof(string)) { return BigInteger.Parse((string)value, formatProvider); }
74else { throw ExceptionBuilder.ConvertFailed(value.GetType(), typeof(System.Numerics.BigInteger)); }
77internal static object ConvertFromBigInteger(BigInteger value, Type type, IFormatProvider formatProvider)
91else if (type == typeof(System.Numerics.BigInteger)) { return value; }
92else { throw ExceptionBuilder.ConvertFailed(typeof(System.Numerics.BigInteger), type); }
119BigInteger value = _values[record];
132_values[record] = BigInteger.Zero;
152return BigInteger.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
159return ((BigInteger)value).ToString("D", System.Globalization.CultureInfo.InvariantCulture);
164return new BigInteger[recordCount];
169BigInteger[] typedStore = (BigInteger[])store;
176_values = (BigInteger[])store;
System.Formats.Asn1 (19)
System.Formats.Cbor (7)
System.Numerics (1)
System.Runtime.Numerics (508)
System\Number.BigInteger.cs (30)
58internal static ParsingStatus TryParseBigInteger<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info, out BigInteger result, out int elementsConsumed)
79internal static unsafe ParsingStatus TryParseBigIntegerNumber<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info, out BigInteger result, out int elementsConsumed)
126internal static BigInteger ParseBigInteger<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info)
134ParsingStatus status = TryParseBigInteger(value, style, info, out BigInteger result, out _);
143internal static ParsingStatus TryParseBigIntegerHexOrBinaryNumberStyle<TParser, TChar>(ReadOnlySpan<TChar> value, NumberStyles style, out BigInteger result, out int elementsConsumed)
271if (totalUIntCount > BigInteger.MaxLength)
300if (bits.Length + 1 > BigInteger.MaxLength)
352private static ParsingStatus NumberToBigInteger(ref NumberBuffer number, out BigInteger result)
399base1E9 = BigInteger.RentedBuffer.Create(base1E9Length, out BigInteger.RentedBuffer base1E9Rental);
424Span<nuint> resultBuffer = BigInteger.RentedBuffer.Create(resultLength, out BigInteger.RentedBuffer resultRental);
456Span<nuint> leading = BigInteger.RentedBuffer.Create(leadingLength, out BigInteger.RentedBuffer leadingBuffer);
496scoped Span<nuint> buffer = BigInteger.RentedBuffer.Create(bufferLength, out BigInteger.RentedBuffer bufferRental);
595private static unsafe string? FormatBigIntegerToHex<TChar>(bool targetSpan, BigInteger value, char format, int digits, NumberFormatInfo info, Span<TChar> destination, out int charsWritten, out bool spanSuccess)
681private static unsafe string? FormatBigIntegerToBinary<TChar>(bool targetSpan, BigInteger value, int digits, Span<TChar> destination, out int charsWritten, out bool spanSuccess)
784internal static string FormatBigInteger(BigInteger value, string? format, NumberFormatInfo info)
789internal static bool TryFormatBigInteger<TChar>(BigInteger value, ReadOnlySpan<char> format, NumberFormatInfo info, Span<TChar> destination, out int charsWritten)
796private static unsafe string? FormatBigInteger<TChar>(bool targetSpan, BigInteger value, string? formatString, ReadOnlySpan<char> formatSpan, NumberFormatInfo info, Span<TChar> destination, out int charsWritten, out bool spanSuccess)
857Debug.Assert(BigInteger.MaxLength * digitRatio + 1 < Array.MaxLength); // won't overflow
860Span<nuint> base1E9Buffer = BigInteger.RentedBuffer.Create(base1E9BufferLength, out BigInteger.RentedBuffer base1E9Rental);
1050Span<nuint> upper = BigInteger.RentedBuffer.Create(upperLength, out BigInteger.RentedBuffer upperBuffer);
1053Span<nuint> lower = BigInteger.RentedBuffer.Create(lowerLength, out BigInteger.RentedBuffer lowerBuffer);
1457Span<nuint> powersOfTen = BigInteger.RentedBuffer.Create(bits.Length, out BigInteger.RentedBuffer powersOfTenBuffer);
System\Numerics\BigInteger.cs (395)
20IComparable<BigInteger>,
21IEquatable<BigInteger>,
22IBinaryInteger<BigInteger>,
23ISignedNumber<BigInteger>,
35/// Maximum number of limbs in a <see cref="BigInteger"/>. Restricts allocations to ~256MB,
59private static readonly BigInteger s_int32MinValue = new(-1, [UInt32HighBit]);
60private static readonly BigInteger s_one = new(1);
61private static readonly BigInteger s_zero = new(0);
62private static readonly BigInteger s_minusOne = new(-1);
689/// Initializes a new <see cref="BigInteger"/> from serialized data.
725/// Populates a <see cref="SerializationInfo"/> with the data needed to serialize the <see cref="BigInteger"/>.
765public static BigInteger Zero => s_zero;
767public static BigInteger One => s_one;
769public static BigInteger MinusOne => s_minusOne;
798public static BigInteger Parse(string value)
803public static BigInteger Parse(string value, NumberStyles style)
808public static BigInteger Parse(string value, IFormatProvider? provider)
813public static BigInteger Parse(string value, NumberStyles style, IFormatProvider? provider)
819public static bool TryParse([NotNullWhen(true)] string? value, out BigInteger result)
824public static bool TryParse([NotNullWhen(true)] string? value, NumberStyles style, IFormatProvider? provider, out BigInteger result)
829public static BigInteger Parse(ReadOnlySpan<char> value, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
834public static BigInteger Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
839public static bool TryParse(ReadOnlySpan<char> value, out BigInteger result)
844public static bool TryParse(ReadOnlySpan<char> value, NumberStyles style, IFormatProvider? provider, out BigInteger result)
849public static bool TryParse(ReadOnlySpan<byte> utf8Text, out BigInteger result)
854public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out BigInteger result)
860static bool INumberBase<BigInteger>.TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out BigInteger result, out int charsConsumed)
866static bool INumberBase<BigInteger>.TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out BigInteger result, out int bytesConsumed)
872static bool INumberBase<BigInteger>.TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out BigInteger result, out int charsConsumed)
877public static int Compare(BigInteger left, BigInteger right)
882public static BigInteger Abs(BigInteger value)
887public static BigInteger Add(BigInteger left, BigInteger right)
892public static BigInteger Subtract(BigInteger left, BigInteger right)
897public static BigInteger Multiply(BigInteger left, BigInteger right)
902public static BigInteger Divide(BigInteger dividend, BigInteger divisor)
907public static BigInteger Remainder(BigInteger dividend, BigInteger divisor)
912public static BigInteger DivRem(BigInteger dividend, BigInteger divisor, out BigInteger remainder)
919BigInteger quotient;
966BigInteger result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
975public static BigInteger Negate(BigInteger value)
980public static double Log(BigInteger value)
985public static double Log(BigInteger value, double baseValue)
1042public static double Log10(BigInteger value)
1047public static BigInteger GreatestCommonDivisor(BigInteger left, BigInteger right)
1080private static BigInteger GreatestCommonDivisor(ReadOnlySpan<nuint> leftBits, ReadOnlySpan<nuint> rightBits)
1084BigInteger result;
1116public static BigInteger Max(BigInteger left, BigInteger right)
1121public static BigInteger Min(BigInteger left, BigInteger right)
1126public static BigInteger ModPow(BigInteger value, BigInteger exponent, BigInteger modulus)
1134BigInteger result;
1177public static BigInteger Pow(BigInteger value, int exponent)
1194BigInteger result;
1248return obj is BigInteger other && Equals(other);
1311public bool Equals(BigInteger other)
1383public int CompareTo(BigInteger other)
1414obj is BigInteger bigInt ? CompareTo(bigInt) :
1889private static BigInteger Add(ReadOnlySpan<nuint> leftBits, int leftSign, ReadOnlySpan<nuint> rightBits, int rightSign)
1896BigInteger result;
1946public static BigInteger operator -(BigInteger left, BigInteger right)
1958private static BigInteger Subtract(ReadOnlySpan<nuint> leftBits, int leftSign, ReadOnlySpan<nuint> rightBits, int rightSign)
1965BigInteger result;
2017public static explicit operator byte(BigInteger value) => checked((byte)((int)value));
2022public static explicit operator char(BigInteger value) => checked((char)((int)value));
2024public static explicit operator decimal(BigInteger value)
2034public static explicit operator double(BigInteger value) => ConvertToDouble(value, roundToOdd: false);
2041private static double ConvertToDouble(BigInteger value, bool roundToOdd)
2151public static explicit operator Half(BigInteger value) => (Half)ConvertToDouble(value, roundToOdd: true);
2156public static explicit operator BFloat16(BigInteger value) => (BFloat16)ConvertToDouble(value, roundToOdd: true);
2158public static explicit operator short(BigInteger value) => checked((short)((int)value));
2160public static explicit operator int(BigInteger value)
2187public static explicit operator long(BigInteger value)
2227public static explicit operator Int128(BigInteger value)
2276public static explicit operator nint(BigInteger value) => Environment.Is64BitProcess ? (nint)(long)value : (int)value;
2279public static explicit operator sbyte(BigInteger value) => checked((sbyte)((int)value));
2281public static explicit operator float(BigInteger value) => (float)ConvertToDouble(value, roundToOdd: true);
2284public static explicit operator ushort(BigInteger value) => checked((ushort)((int)value));
2287public static explicit operator uint(BigInteger value)
2302public static explicit operator ulong(BigInteger value)
2330public static explicit operator UInt128(BigInteger value)
2370public static explicit operator nuint(BigInteger value) => Environment.Is64BitProcess ? (nuint)(ulong)value : (uint)value;
2376public static explicit operator BigInteger(decimal value) => new BigInteger(value);
2378public static explicit operator BigInteger(double value) => new BigInteger(value);
2383public static explicit operator BigInteger(Half value) => new BigInteger((float)value);
2388public static explicit operator BigInteger(BFloat16 value) => new BigInteger((float)value);
2393public static explicit operator BigInteger(Complex value)
2400return (BigInteger)value.Real;
2403public static explicit operator BigInteger(float value) => new BigInteger(value);
2409public static implicit operator BigInteger(byte value) => new BigInteger(value);
2414public static implicit operator BigInteger(char value) => new BigInteger(value);
2416public static implicit operator BigInteger(short value) => new BigInteger(value);
2418public static implicit operator BigInteger(int value) => new BigInteger(value);
2420public static implicit operator BigInteger(long value) => new BigInteger(value);
2425public static implicit operator BigInteger(Int128 value)
2493public static implicit operator BigInteger(nint value) => new BigInteger(value);
2496public static implicit operator BigInteger(sbyte value) => new BigInteger(value);
2499public static implicit operator BigInteger(ushort value) => new BigInteger(value);
2502public static implicit operator BigInteger(uint value) => new BigInteger(value);
2505public static implicit operator BigInteger(ulong value) => new BigInteger(value);
2511public static implicit operator BigInteger(UInt128 value)
2563public static implicit operator BigInteger(nuint value) => value <= int.MaxValue ? new BigInteger((int)value, null) : new BigInteger(+1, [value]);
2565public static BigInteger operator &(BigInteger left, BigInteger right) =>
2567left._bits is null && right._bits is null ? (BigInteger)(left._sign & right._sign) :
2570public static BigInteger operator |(BigInteger left, BigInteger right)
2583? (BigInteger)(left._sign | right._sign)
2587public static BigInteger operator ^(BigInteger left, BigInteger right) =>
2589? (BigInteger)(left._sign ^ right._sign)
2596private static BigInteger BitwiseAnd(ref readonly BigInteger left, ref readonly BigInteger right)
2615private static BigInteger BitwiseOr(ref readonly BigInteger left, ref readonly BigInteger right)
2625private static BigInteger BitwiseXor(ref readonly BigInteger left, ref readonly BigInteger right)
2632private static BigInteger BitwiseOp<TOp>(ref readonly BigInteger left, ref readonly BigInteger right, int zLen)
2642BigInteger result = new(z);
2649public static BigInteger operator <<(BigInteger value, int shift)
2707private static BigInteger LeftShift(int value, int digitShift, int smallShift)
2743public static BigInteger operator >>(BigInteger value, int shift)
2804BigInteger result = new(zd, neg);
2811public static BigInteger operator ~(BigInteger value)
2820BigInteger result;
2845public static BigInteger operator -(BigInteger value) => new BigInteger(-value._sign, value._bits);
2847public static BigInteger operator +(BigInteger value) => value;
2849public static BigInteger operator ++(BigInteger value)
2856BigInteger result;
2879public static BigInteger operator --(BigInteger value)
2886BigInteger result;
2909public static BigInteger operator +(BigInteger left, BigInteger right)
2921public static BigInteger operator *(BigInteger left, BigInteger right) =>
2923? (BigInteger)((long)left._sign * right._sign)
2926private static BigInteger Multiply(ReadOnlySpan<nuint> left, int leftSign, ReadOnlySpan<nuint> right, int rightSign)
2933BigInteger result;
2981public static BigInteger operator /(BigInteger dividend, BigInteger divisor)
3008BigInteger result = new BigInteger(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3027BigInteger result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3035public static BigInteger operator %(BigInteger dividend, BigInteger divisor)
3070BigInteger result = new(bits, dividend._sign < 0);
3077public static bool operator <(BigInteger left, BigInteger right) => left.CompareTo(right) < 0;
3079public static bool operator <=(BigInteger left, BigInteger right) => left.CompareTo(right) <= 0;
3081public static bool operator >(BigInteger left, BigInteger right) => left.CompareTo(right) > 0;
3083public static bool operator >=(BigInteger left, BigInteger right) => left.CompareTo(right) >= 0;
3085public static bool operator ==(BigInteger left, BigInteger right) => left.Equals(right);
3087public static bool operator !=(BigInteger left, BigInteger right) => !left.Equals(right);
3089public static bool operator <(BigInteger left, long right) => left.CompareTo(right) < 0;
3091public static bool operator <=(BigInteger left, long right) => left.CompareTo(right) <= 0;
3093public static bool operator >(BigInteger left, long right) => left.CompareTo(right) > 0;
3095public static bool operator >=(BigInteger left, long right) => left.CompareTo(right) >= 0;
3097public static bool operator ==(BigInteger left, long right) => left.Equals(right);
3099public static bool operator !=(BigInteger left, long right) => !left.Equals(right);
3101public static bool operator <(long left, BigInteger right) => right.CompareTo(left) > 0;
3103public static bool operator <=(long left, BigInteger right) => right.CompareTo(left) >= 0;
3105public static bool operator >(long left, BigInteger right) => right.CompareTo(left) < 0;
3107public static bool operator >=(long left, BigInteger right) => right.CompareTo(left) <= 0;
3109public static bool operator ==(long left, BigInteger right) => right.Equals(left);
3111public static bool operator !=(long left, BigInteger right) => !right.Equals(left);
3114public static bool operator <(BigInteger left, ulong right) => left.CompareTo(right) < 0;
3117public static bool operator <=(BigInteger left, ulong right) => left.CompareTo(right) <= 0;
3120public static bool operator >(BigInteger left, ulong right) => left.CompareTo(right) > 0;
3123public static bool operator >=(BigInteger left, ulong right) => left.CompareTo(right) >= 0;
3126public static bool operator ==(BigInteger left, ulong right) => left.Equals(right);
3129public static bool operator !=(BigInteger left, ulong right) => !left.Equals(right);
3132public static bool operator <(ulong left, BigInteger right) => right.CompareTo(left) > 0;
3135public static bool operator <=(ulong left, BigInteger right) => right.CompareTo(left) >= 0;
3138public static bool operator >(ulong left, BigInteger right) => right.CompareTo(left) < 0;
3141public static bool operator >=(ulong left, BigInteger right) => right.CompareTo(left) <= 0;
3144public static bool operator ==(ulong left, BigInteger right) => right.Equals(left);
3147public static bool operator !=(ulong left, BigInteger right) => !right.Equals(left);
3220static BigInteger IAdditiveIdentity<BigInteger, BigInteger>.AdditiveIdentity => Zero;
3227static BigInteger IBinaryInteger<BigInteger>.Log10(BigInteger value)
3249BigInteger log2Value = Log2(value);
3250BigInteger approx = ((log2Value + 1) * 1292913986L) >> 32;
3251BigInteger power = Pow(10, (int)approx);
3257public static (BigInteger Quotient, BigInteger Remainder) DivRem(BigInteger left, BigInteger right)
3259BigInteger quotient = DivRem(left, right, out BigInteger remainder);
3264public static BigInteger LeadingZeroCount(BigInteger value)
3286public static BigInteger PopCount(BigInteger value)
3341public static BigInteger RotateLeft(BigInteger value, int rotateAmount)
3362public static BigInteger RotateRight(BigInteger value, int rotateAmount)
3382private static BigInteger Rotate(ReadOnlySpan<nuint> bits, bool negative, long rotateLeftAmount)
3569BigInteger result = new(zd, negative);
3594private static BigInteger RotateNuint(ReadOnlySpan<nuint> bits, bool negative, long rotateLeftAmount)
3631BigInteger result = new(zd, negative);
3639public static BigInteger TrailingZeroCount(BigInteger value)
3665static bool IBinaryInteger<BigInteger>.TryReadBigEndian(ReadOnlySpan<byte> source, bool isUnsigned, out BigInteger value)
3672static bool IBinaryInteger<BigInteger>.TryReadLittleEndian(ReadOnlySpan<byte> source, bool isUnsigned, out BigInteger value)
3679int IBinaryInteger<BigInteger>.GetShortestBitLength()
3716int IBinaryInteger<BigInteger>.GetByteCount() => GetGenericMathByteCount();
3719bool IBinaryInteger<BigInteger>.TryWriteBigEndian(Span<byte> destination, out int bytesWritten)
3797bool IBinaryInteger<BigInteger>.TryWriteLittleEndian(Span<byte> destination, out int bytesWritten)
3912static BigInteger IBinaryNumber<BigInteger>.AllBitsSet => MinusOne;
3915public static bool IsPow2(BigInteger value) => value.IsPowerOfTwo;
3918public static BigInteger Log2(BigInteger value)
3926? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1))
3927: (BigInteger)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1]));
3935static BigInteger IMultiplicativeIdentity<BigInteger, BigInteger>.MultiplicativeIdentity => One;
3942public static BigInteger Clamp(BigInteger value, BigInteger min, BigInteger max)
3968public static BigInteger CopySign(BigInteger value, BigInteger sign)
3988static BigInteger INumber<BigInteger>.MaxNumber(BigInteger x, BigInteger y) => Max(x, y);
3991static BigInteger INumber<BigInteger>.MinNumber(BigInteger x, BigInteger y) => Min(x, y);
3994static int INumber<BigInteger>.Sign(BigInteger value)
4006static int INumberBase<BigInteger>.Radix => 2;
4010public static BigInteger CreateChecked<TOther>(TOther value)
4013BigInteger result;
4015if (typeof(TOther) == typeof(BigInteger))
4017result = (BigInteger)(object)value;
4029public static BigInteger CreateSaturating<TOther>(TOther value)
4032BigInteger result;
4034if (typeof(TOther) == typeof(BigInteger))
4036result = (BigInteger)(object)value;
4048public static BigInteger CreateTruncating<TOther>(TOther value)
4051BigInteger result;
4053if (typeof(TOther) == typeof(BigInteger))
4055result = (BigInteger)(object)value;
4066static bool INumberBase<BigInteger>.IsCanonical(BigInteger value) => true;
4069static bool INumberBase<BigInteger>.IsComplexNumber(BigInteger value) => false;
4072public static bool IsEvenInteger(BigInteger value)
4080static bool INumberBase<BigInteger>.IsFinite(BigInteger value) => true;
4083static bool INumberBase<BigInteger>.IsImaginaryNumber(BigInteger value) => false;
4086static bool INumberBase<BigInteger>.IsInfinity(BigInteger value) => false;
4089static bool INumberBase<BigInteger>.IsInteger(BigInteger value) => true;
4092static bool INumberBase<BigInteger>.IsNaN(BigInteger value) => false;
4095public static bool IsNegative(BigInteger value)
4101static bool INumberBase<BigInteger>.IsNegativeInfinity(BigInteger value) => false;
4104static bool INumberBase<BigInteger>.IsNormal(BigInteger value) => (value != 0);
4107public static bool IsOddInteger(BigInteger value)
4115public static bool IsPositive(BigInteger value)
4121static bool INumberBase<BigInteger>.IsPositiveInfinity(BigInteger value) => false;
4124static bool INumberBase<BigInteger>.IsRealNumber(BigInteger value) => true;
4127static bool INumberBase<BigInteger>.IsSubnormal(BigInteger value) => false;
4130static bool INumberBase<BigInteger>.IsZero(BigInteger value)
4136public static BigInteger MaxMagnitude(BigInteger x, BigInteger y)
4143static BigInteger INumberBase<BigInteger>.MaxMagnitudeNumber(BigInteger x, BigInteger y) => MaxMagnitude(x, y);
4146public static BigInteger MinMagnitude(BigInteger x, BigInteger y)
4153static BigInteger INumberBase<BigInteger>.MinMagnitudeNumber(BigInteger x, BigInteger y) => MinMagnitude(x, y);
4156static BigInteger INumberBase<BigInteger>.MultiplyAddEstimate(BigInteger left, BigInteger right, BigInteger addend) => (left * right) + addend;
4160static bool INumberBase<BigInteger>.TryConvertFromChecked<TOther>(TOther value, out BigInteger result) => TryConvertFromChecked(value, out result);
4163private static bool TryConvertFromChecked<TOther>(TOther value, out BigInteger result)
4181result = (BigInteger)actualValue;
4187result = checked((BigInteger)actualValue);
4193result = checked((BigInteger)actualValue);
4199result = checked((BigInteger)actualValue);
4241result = checked((BigInteger)actualValue);
4283static bool INumberBase<BigInteger>.TryConvertFromSaturating<TOther>(TOther value, out BigInteger result) => TryConvertFromSaturating(value, out result);
4286private static bool TryConvertFromSaturating<TOther>(TOther value, out BigInteger result)
4304result = (BigInteger)actualValue;
4310result = double.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4316result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4322result = BFloat16.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4364result = float.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4406static bool INumberBase<BigInteger>.TryConvertFromTruncating<TOther>(TOther value, out BigInteger result) => TryConvertFromTruncating(value, out result);
4409private static bool TryConvertFromTruncating<TOther>(TOther value, out BigInteger result)
4427result = (BigInteger)actualValue;
4433result = double.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4439result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4445result = BFloat16.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4487result = float.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4529static bool INumberBase<BigInteger>.TryConvertToChecked<TOther>(BigInteger value, [MaybeNullWhen(false)] out TOther result)
4654static bool INumberBase<BigInteger>.TryConvertToSaturating<TOther>(BigInteger value, [MaybeNullWhen(false)] out TOther result)
4853static bool INumberBase<BigInteger>.TryConvertToTruncating<TOther>(BigInteger value, [MaybeNullWhen(false)] out TOther result)
5284public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out BigInteger result) => TryParse(s, NumberStyles.Integer, provider, out result);
5291public static BigInteger operator >>>(BigInteger value, int shiftAmount)
5400BigInteger result;
5427static BigInteger ISignedNumber<BigInteger>.NegativeOne => MinusOne;
5434public static BigInteger Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, NumberStyles.Integer, provider);
5437public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out BigInteger result) => TryParse(s, NumberStyles.Integer, provider, out result);
5444public static BigInteger Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, NumberStyles.Integer, provider);
5447public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out BigInteger result) => TryParse(utf8Text, NumberStyles.Integer, provider, out result);
System\Numerics\BigIntegerCalculator.DivRem.cs (24)
99Span<nuint> leftCopy = BigInteger.RentedBuffer.Create(left.Length, out BigInteger.RentedBuffer leftCopyBuffer);
131Span<nuint> quotient = BigInteger.RentedBuffer.Create(quotientLength, out BigInteger.RentedBuffer quotientBuffer);
163Span<nuint> leftCopy = BigInteger.RentedBuffer.Create(left.Length, out BigInteger.RentedBuffer leftCopyBuffer);
167Span<nuint> quotientAllocated = BigInteger.RentedBuffer.Create(quotientLength, out BigInteger.RentedBuffer quotientActualBuffer);
336Span<nuint> b = BigInteger.RentedBuffer.Create(n, out BigInteger.RentedBuffer bBuffer);
349Span<nuint> a = BigInteger.RentedBuffer.Create(aLength, out BigInteger.RentedBuffer aBuffer);
385Span<nuint> r = BigInteger.RentedBuffer.Create(n + 1, out BigInteger.RentedBuffer rBuffer);
387Span<nuint> z = BigInteger.RentedBuffer.Create(2 * n, out BigInteger.RentedBuffer zBuffer);
394Span<nuint> q = BigInteger.RentedBuffer.Create(n, out BigInteger.RentedBuffer qBuffer);
501Span<nuint> r1 = BigInteger.RentedBuffer.Create(left.Length, out BigInteger.RentedBuffer r1Buffer);
541Span<nuint> r1 = BigInteger.RentedBuffer.Create(right.Length + 1, out BigInteger.RentedBuffer r1Buffer);
566Span<nuint> d = BigInteger.RentedBuffer.Create(right.Length, out BigInteger.RentedBuffer dBuffer);
System\Numerics\BigIntegerCalculator.PowMod.cs (30)
25Span<nuint> temp = BigInteger.RentedBuffer.Create(bits.Length, out BigInteger.RentedBuffer tempBuffer);
27Span<nuint> valueCopy = BigInteger.RentedBuffer.Create(bits.Length, out BigInteger.RentedBuffer valueCopyBuffer);
267Span<nuint> valueCopy = BigInteger.RentedBuffer.Create(size, out BigInteger.RentedBuffer valueCopyBuffer);
283Span<nuint> temp = BigInteger.RentedBuffer.Create(bits.Length, out BigInteger.RentedBuffer tempBuffer);
307Span<nuint> valueCopy = BigInteger.RentedBuffer.Create(size, out BigInteger.RentedBuffer valueCopyBuffer);
323Span<nuint> temp = BigInteger.RentedBuffer.Create(bits.Length, out BigInteger.RentedBuffer tempBuffer);
392Span<nuint> r = BigInteger.RentedBuffer.Create(size, out BigInteger.RentedBuffer rBuffer);
395Span<nuint> mu = BigInteger.RentedBuffer.Create(size, out BigInteger.RentedBuffer muBuffer);
398Span<nuint> q1 = BigInteger.RentedBuffer.Create(size, out BigInteger.RentedBuffer q1Buffer);
400Span<nuint> q2 = BigInteger.RentedBuffer.Create(size, out BigInteger.RentedBuffer q2Buffer);
496Span<nuint> shifted = BigInteger.RentedBuffer.Create(shiftLen, out BigInteger.RentedBuffer shiftedBuffer);
511Span<nuint> rModN = BigInteger.RentedBuffer.Create(k, out BigInteger.RentedBuffer rModNBuffer);
514Span<nuint> oneShifted = BigInteger.RentedBuffer.Create(oneShiftLen, out BigInteger.RentedBuffer oneShiftedBuffer);
563Span<nuint> prod = BigInteger.RentedBuffer.Create(bufLen, out BigInteger.RentedBuffer prodBuffer);
566Span<nuint> base2 = BigInteger.RentedBuffer.Create(k, out BigInteger.RentedBuffer base2Buffer);
System.Security.Cryptography (33)
System.Security.Cryptography.Cose (1)
System.Security.Cryptography.Pkcs (1)
System.Security.Cryptography.Xml (3)