115 instantiations of BigInteger
Microsoft.CodeAnalysis (2)
RealParser.cs (2)
62
private static readonly BigInteger s_bigTwo = new
BigInteger
(2);
63
private static readonly BigInteger s_bigTen = new
BigInteger
(10);
Microsoft.Gen.Logging.Generated.Tests (1)
LogPropertiesTests.cs (1)
100
P10 = new
BigInteger
(3.1415),
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (1)
parent\parent\StaticWebAssetsSdk\Tasks\Utils\FileHasher.cs (1)
42
var dividend = BigInteger.Abs(new
BigInteger
(hash.AsSpan()[..9].ToArray()));
Microsoft.NET.Sdk.StaticWebAssets.Tasks (2)
ScopedCss\ComputeCssScope.cs (1)
67
var dividend = BigInteger.Abs(new
BigInteger
([.. hash.AsSpan()[..9]]));
Utils\FileHasher.cs (1)
42
var dividend = BigInteger.Abs(new
BigInteger
(hash.AsSpan()[..9].ToArray()));
NuGet.Packaging (3)
Signing\DerEncoding\DerEncoder.cs (1)
1005
BigInteger divisor = new
BigInteger
(128);
Signing\DerEncoding\DerSequenceReader.cs (2)
228
BigInteger bigInt = new
BigInteger
(integerBytes);
301
BigInteger bigInt = new
BigInteger
(0);
System.Formats.Asn1 (2)
System\Formats\Asn1\AsnDecoder.Integer.cs (1)
108
BigInteger value = new
BigInteger
(contents, isBigEndian: true);
System\Formats\Asn1\AsnDecoder.Oid.cs (1)
225
largeValue = new
BigInteger
(tmpBytes);
System.Formats.Cbor (1)
System\Formats\Cbor\CborHelpers.netcoreapp.cs (1)
13
=> new
BigInteger
(bytes, isUnsigned: true, isBigEndian: true);
System.Runtime.Numerics (89)
System\Number.BigInteger.cs (6)
266
result = new
BigInteger
((int)signedLeading, null);
276
result = new
BigInteger
((int)signBits | 1, [(leading ^ signBits) - signBits]);
282
result = new
BigInteger
(-1, [0, 1]);
332
result = new
BigInteger
(-1, bits);
341
result = new
BigInteger
(1, bits);
459
result = new
BigInteger
(resultBuffer, number.IsNegative);
System\Numerics\BigInteger.cs (83)
63
private static readonly BigInteger s_int32MinValue =
new
(-1, [UInt32HighBit]);
64
private static readonly BigInteger s_one =
new
(1);
65
private static readonly BigInteger s_zero =
new
(0);
66
private static readonly BigInteger s_minusOne =
new
(-1);
888
return new
BigInteger
((int)NumericsHelpers.Abs(value._sign), value._bits);
949
return new
BigInteger
(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
990
remainder =
new
(rest, dividend._sign < 0);
991
BigInteger result =
new
(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
1107
: new
BigInteger
(+1, right._bits);
1115
: new
BigInteger
(+1, left._bits);
1165
result = new
BigInteger
(bits, negative: false);
1272
return new
BigInteger
(dividendBits[..limbCount], dividend._sign < 0);
1278
BigInteger remainder =
new
(bits, dividend._sign < 0);
1373
result = new
BigInteger
(bits, value._sign < 0 && !exponent.IsEven);
1445
result = new
BigInteger
(genericBits, value._sign < 0 && (exponent & 1) != 0);
1522
? new
BigInteger
((int)exactBits[0])
1523
: new
BigInteger
(exactBits, negative: false);
1660
result = new
BigInteger
(bits, value._sign < 0 && (exponent & 1) != 0);
1669
result = new
BigInteger
(bits, value._sign < 0 && (exponent & 1) != 0);
2358
result = new
BigInteger
(bits, leftSign < 0);
2369
result = new
BigInteger
(bits, leftSign < 0);
2380
result = new
BigInteger
(bits, leftSign < 0);
2391
result = new
BigInteger
(bits, leftSign < 0);
2436
result = new
BigInteger
(bits, leftSign >= 0);
2447
result = new
BigInteger
(bits, leftSign < 0);
2456
result = new
BigInteger
(bits, leftSign >= 0);
2467
result = new
BigInteger
(bits, leftSign < 0);
2502
result = new
BigInteger
(bits, leftSign < 0);
2530
result = new
BigInteger
(bits, compare < 0 ? leftSign >= 0 : leftSign < 0);
3007
public static explicit operator BigInteger(decimal value) => new
BigInteger
(value);
3009
public static explicit operator BigInteger(double value) => new
BigInteger
(value);
3014
public static explicit operator BigInteger(Half value) => new
BigInteger
((float)value);
3019
public static explicit operator BigInteger(BFloat16 value) => new
BigInteger
((float)value);
3034
public static explicit operator BigInteger(float value) => new
BigInteger
(value);
3040
public static implicit operator BigInteger(byte value) => new
BigInteger
(value);
3045
public static implicit operator BigInteger(char value) => new
BigInteger
(value);
3047
public static implicit operator BigInteger(short value) => new
BigInteger
(value);
3049
public static implicit operator BigInteger(int value) => new
BigInteger
(value);
3051
public static implicit operator BigInteger(long value) => new
BigInteger
(value);
3118
return new
BigInteger
(sign, bits);
3124
public static implicit operator BigInteger(nint value) => new
BigInteger
(value);
3127
public static implicit operator BigInteger(sbyte value) => new
BigInteger
(value);
3130
public static implicit operator BigInteger(ushort value) => new
BigInteger
(value);
3133
public static implicit operator BigInteger(uint value) => new
BigInteger
(value);
3136
public static implicit operator BigInteger(ulong value) => new
BigInteger
(value);
3187
return new
BigInteger
(sign, bits);
3194
public static implicit operator BigInteger(nuint value) => value <= int.MaxValue ? new
BigInteger
((int)value, null) : new
BigInteger
(+1, [value]);
3273
BigInteger result =
new
(z);
3345
return new
BigInteger
(value._sign, z);
3368
return new
BigInteger
(value >= 0 ? (int)r : -(int)r, null);
3391
return new
BigInteger
(value > 0 ? 1 : -1, rgu);
3423
return new
BigInteger
(value._sign >> smallShift, null);
3434
return new
BigInteger
(value._sign >> 31, null);
3455
BigInteger result =
new
(zd, neg);
3480
result = new
BigInteger
(bits, negative: true);
3489
result = new
BigInteger
(bits, negative: false);
3496
public static BigInteger operator -(BigInteger value) => new
BigInteger
(-value._sign, value._bits);
3515
result = new
BigInteger
(bits, negative: false);
3523
result = new
BigInteger
(bits, negative: true);
3544
result = new
BigInteger
(bits, negative: false);
3553
result = new
BigInteger
(bits, negative: true);
3611
result = new
BigInteger
(bits, (leftSign < 0) ^ (rightSign < 0));
3622
result = new
BigInteger
(bits, (leftSign < 0) ^ (rightSign < 0));
3631
result = new
BigInteger
(bits, (leftSign < 0) ^ (rightSign < 0));
3642
result = new
BigInteger
(bits, (leftSign < 0) ^ (rightSign < 0));
3676
BigInteger result = new
BigInteger
(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3713
BigInteger result =
new
(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3775
BigInteger result =
new
(bits, dividend._sign < 0);
4062
? new
BigInteger
((int)rs)
4063
: new
BigInteger
(rs);
4083
? new
BigInteger
((int)rs)
4084
: new
BigInteger
(rs);
4277
BigInteger result =
new
(zd, negative);
4339
BigInteger result =
new
(zd, negative);
4378
value = new
BigInteger
(source, isUnsigned, isBigEndian: true);
4385
value = new
BigInteger
(source, isUnsigned, isBigEndian: false);
6030
return new
BigInteger
((nint)value._sign >>> smallShift);
6071
return new
BigInteger
(nint.MinValue >>> smallShift);
6076
return new
BigInteger
(smallShift == 0 ? -1 : +1, rgu);
6119
result = new
BigInteger
(zd, true);
6123
result = new
BigInteger
(zd, false);
6131
return new
BigInteger
(value._sign >> 31, null);
System.Security.Cryptography (10)
src\runtime\src\libraries\Common\src\System\Security\Cryptography\DSAKeyFormatHelper.cs (7)
43
x = new
BigInteger
(xSpan, isUnsigned: true, isBigEndian: true);
52
BigInteger p = new
BigInteger
(parms.P, isBigEndian: true);
53
BigInteger q = new
BigInteger
(parms.Q, isBigEndian: true);
54
BigInteger g = new
BigInteger
(parms.G, isBigEndian: true);
121
BigInteger p = new
BigInteger
(parms.P, isBigEndian: true);
122
BigInteger q = new
BigInteger
(parms.Q, isBigEndian: true);
123
BigInteger g = new
BigInteger
(parms.G, isBigEndian: true);
System\Security\Cryptography\X509Certificates\FindPal.cs (2)
95
BigInteger hexValue = new
BigInteger
(hexBytes, isUnsigned: true, isBigEndian: true);
245
BigInteger ten = new
BigInteger
(10);
System\Security\Cryptography\X509Certificates\FindPal.Windows.cs (1)
101
BigInteger actualAsBigInteger = new
BigInteger
(actual, isUnsigned: true);
System.Security.Cryptography.Cose (1)
System\Security\Cryptography\Cose\CoseHelpers.cs (1)
183
=> throw new CryptographicException(SR.Format(SR.Sign1UnknownCoseAlgorithm, BigInteger.MinusOne - new
BigInteger
(alg)));
System.Security.Cryptography.Pkcs (2)
System\Security\Cryptography\Pkcs\CmsSignature.cs (2)
244
BigInteger val = new
BigInteger
(
252
val = new
BigInteger
(
System.Security.Cryptography.Xml (1)
System\Security\Cryptography\Xml\KeyInfoX509Data.cs (1)
171
h = new
BigInteger
(bytes);
724 references to BigInteger
Microsoft.AspNetCore.Http.Extensions (4)
src\aspnetcore\src\Shared\ParameterBindingMethodCache.cs (4)
661
else if (type == typeof(
BigInteger
))
663
method = typeof(
BigInteger
).GetMethod(
664
nameof(
BigInteger
.TryParse),
666
new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider), typeof(
BigInteger
).MakeByRefType() });
Microsoft.AspNetCore.Mvc.Abstractions (4)
src\aspnetcore\src\Shared\ParameterBindingMethodCache.cs (4)
661
else if (type == typeof(
BigInteger
))
663
method = typeof(
BigInteger
).GetMethod(
664
nameof(
BigInteger
.TryParse),
666
new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider), typeof(
BigInteger
).MakeByRefType() });
Microsoft.AspNetCore.OpenApi (4)
src\aspnetcore\src\Shared\ParameterBindingMethodCache.cs (4)
661
else if (type == typeof(
BigInteger
))
663
method = typeof(
BigInteger
).GetMethod(
664
nameof(
BigInteger
.TryParse),
666
new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider), typeof(
BigInteger
).MakeByRefType() });
Microsoft.CodeAnalysis (25)
RealParser.cs (22)
60
private static readonly
BigInteger
s_bigZero =
BigInteger
.Zero;
61
private static readonly
BigInteger
s_bigOne =
BigInteger
.One;
62
private static readonly
BigInteger
s_bigTwo = new BigInteger(2);
63
private static readonly
BigInteger
s_bigTen = new BigInteger(10);
415
BigInteger
integerValue = AccumulateDecimalDigitsIntoBigInteger(data, integerFirstIndex, integerLastIndex);
465
BigInteger
fractionalNumerator = AccumulateDecimalDigitsIntoBigInteger(data, fractionalFirstIndex, fractionalLastIndex);
468
BigInteger
fractionalDenominator = s_bigOne;
531
BigInteger
fractionalRemainder;
532
BigInteger
bigFractionalMantissa =
BigInteger
.DivRem(fractionalNumerator, fractionalDenominator, out fractionalRemainder);
621
private static
BigInteger
AccumulateDecimalDigitsIntoBigInteger(DecimalFloatingPointString data, uint integer_first_index, uint integer_last_index)
625
return
BigInteger
.Parse(valueString);
661
private static uint CountSignificantBits(
BigInteger
data, out byte[] dataBytes)
682
private static uint CountSignificantBits(
BigInteger
data)
750
private static void ShiftLeft(ref
BigInteger
number, uint shift)
752
var
powerOfTwo =
BigInteger
.Pow(s_bigTwo, (int)shift);
761
private static void MultiplyByPowerOfTen(ref
BigInteger
number, uint power)
763
var
powerOfTen =
BigInteger
.Pow(s_bigTen, (int)power);
VersionHelper.cs (3)
118
System.Numerics.
BigInteger
number = 0;
164
System.Numerics.
BigInteger
number;
165
if (System.Numerics.
BigInteger
.TryParse(s, NumberStyles.None, CultureInfo.InvariantCulture, out number))
Microsoft.Gen.Logging.Generated.Tests (1)
test\Generators\Microsoft.Gen.Logging\TestClasses\LogPropertiesSpecialTypesExtensions.cs (1)
27
public
BigInteger
P10 { get; set; }
Microsoft.Gen.Logging.Unit.Tests (3)
CompilationHelper.cs (1)
37
refs.Add(MetadataReference.CreateFromFile(typeof(
BigInteger
).Assembly.Location));
EmitterTests.cs (1)
47
Assembly.GetAssembly(typeof(
BigInteger
))!,
ParserTests.cs (1)
727
Assembly.GetAssembly(typeof(
BigInteger
))!,
Microsoft.ML.Parquet (2)
ParquetLoader.cs (2)
517
return CreateGetterDelegateCore<
BigInteger
, DataViewRowId>(col, _parquetConversions.Conv);
725
public void Conv(in
BigInteger
src, ref DataViewRowId dst)
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (4)
parent\parent\StaticWebAssetsSdk\Tasks\Utils\FileHasher.cs (4)
42
var
dividend =
BigInteger
.Abs(new BigInteger(hash.AsSpan()[..9].ToArray()));
48
dividend =
BigInteger
.DivRem(dividend, 36, out
var
remainder);
Microsoft.NET.Sdk.StaticWebAssets.Tasks (8)
ScopedCss\ComputeCssScope.cs (4)
67
var
dividend =
BigInteger
.Abs(new BigInteger([.. hash.AsSpan()[..9]]));
73
dividend =
BigInteger
.DivRem(dividend, 36, out
var
remainder);
Utils\FileHasher.cs (4)
42
var
dividend =
BigInteger
.Abs(new BigInteger(hash.AsSpan()[..9].ToArray()));
48
dividend =
BigInteger
.DivRem(dividend, 36, out
var
remainder);
netstandard (1)
netstandard.cs (1)
1331
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.
BigInteger
))]
NuGet.Packaging (12)
Signing\DerEncoding\DerEncoder.cs (10)
485
BigInteger
rid = ParseOidRid(oidValue, ref startPos);
966
private static
BigInteger
ParseOidRid(string oidValue, ref int startIndex)
983
BigInteger
value =
BigInteger
.Zero;
1003
private static void EncodeRid(List<byte> encodedData, ref
BigInteger
rid)
1005
BigInteger
divisor = new BigInteger(128);
1006
BigInteger
unencoded = rid;
1018
BigInteger
remainder;
1019
unencoded =
BigInteger
.DivRem(unencoded, divisor, out remainder);
1028
while (unencoded !=
BigInteger
.Zero);
Signing\DerEncoding\DerSequenceReader.cs (2)
228
BigInteger
bigInt = new BigInteger(integerBytes);
301
BigInteger
bigInt = new BigInteger(0);
PresentationBuildTasks (3)
MS\Internal\MarkupCompiler\VersionHelper.cs (3)
114
System.Numerics.
BigInteger
number = 0;
163
System.Numerics.
BigInteger
number;
164
if (System.Numerics.
BigInteger
.TryParse(s, NumberStyles.None, CultureInfo.InvariantCulture, out number))
System.Data.Common (51)
System\Data\Common\BigIntegerStorage.cs (23)
13
private
BigInteger
[] _values = default!; // Late-initialized
16
base(column, typeof(
BigInteger
),
BigInteger
.Zero, StorageType.BigInteger)
27
BigInteger
valueNo1 = _values[recordNo1];
28
BigInteger
valueNo2 = _values[recordNo2];
52
BigInteger
valueNo1 = _values[recordNo];
58
return valueNo1.CompareTo((
BigInteger
)value);
62
internal static
BigInteger
ConvertToBigInteger(object value, IFormatProvider formatProvider)
64
if (value.GetType() == typeof(
BigInteger
)) { return (
BigInteger
)value; }
65
else if (value.GetType() == typeof(string)) { return
BigInteger
.Parse((string)value, formatProvider); }
74
else { throw ExceptionBuilder.ConvertFailed(value.GetType(), typeof(System.Numerics.
BigInteger
)); }
77
internal static object ConvertFromBigInteger(
BigInteger
value, Type type, IFormatProvider formatProvider)
91
else if (type == typeof(System.Numerics.
BigInteger
)) { return value; }
92
else { throw ExceptionBuilder.ConvertFailed(typeof(System.Numerics.
BigInteger
), type); }
119
BigInteger
value = _values[record];
132
_values[record] =
BigInteger
.Zero;
152
return
BigInteger
.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
159
return ((
BigInteger
)value).ToString("D", System.Globalization.CultureInfo.InvariantCulture);
164
return new
BigInteger
[recordCount];
169
BigInteger
[] typedStore = (
BigInteger
[])store;
176
_values = (
BigInteger
[])store;
System\Data\Common\DataStorage.cs (2)
92
typeof(System.Numerics.
BigInteger
),
579
dataType = typeof(System.Numerics.
BigInteger
);
System\Data\Common\SQLConvert.cs (3)
350
if (type == typeof(System.Numerics.
BigInteger
))
355
else if (value is System.Numerics.
BigInteger
)
357
return BigIntegerStorage.ConvertFromBigInteger((System.Numerics.
BigInteger
)value, type, formatProvider);
System\Data\DataColumn.cs (17)
262
if ((
BigInteger
)AutoIncrementSeed != BigIntegerStorage.ConvertToBigInteger(value, FormatProvider))
270
(_autoInc ??= ((DataType == typeof(
BigInteger
)) ?
512
if (_defaultValue is
BigInteger
)
514
_defaultValue = BigIntegerStorage.ConvertFromBigInteger((
BigInteger
)_defaultValue, value, FormatProvider);
516
else if (typeof(
BigInteger
) == value)
584
AutoInc.Current = (
BigInteger
)(long)inc.Current;
588
AutoInc.Current = checked((long)(
BigInteger
)inc.Current);
1608
dataType == typeof(
BigInteger
) ||
1956
Debug.Assert(null != value && DataColumn.IsAutoIncrementType(value.GetType()) && !(value is
BigInteger
), "unexpected value for autoincrement");
1964
private bool BoundaryCheck(
BigInteger
value) =>
1972
private
BigInteger
_current;
1978
private
BigInteger
_step = 1;
1984
set { _current = (
BigInteger
)value; }
1987
internal override Type DataType => typeof(
BigInteger
);
2037
BigInteger
v = (
BigInteger
)value;
2044
private bool BoundaryCheck(
BigInteger
value) =>
System\Data\TypeLimiter.cs (1)
170
typeof(
BigInteger
),
System\Data\xmlsaver.cs (5)
87
else if (entry.Value is System.Numerics.
BigInteger
)
89
v = (string)BigIntegerStorage.ConvertFromBigInteger((System.Numerics.
BigInteger
)entry.Value, typeof(string), CultureInfo.InvariantCulture);
199
if (bIsSqlType || (col.DataType == typeof(System.Numerics.
BigInteger
)))
265
if (type == typeof(System.Numerics.
BigInteger
))
1348
if ((col.IsSqlType && ((dt.Length == 0) || col.ImplementsINullable)) || (typeof(SqlXml) == col.DataType) || col.DataType == typeof(DateTimeOffset) || col.DataType == typeof(System.Numerics.
BigInteger
))
System.Formats.Asn1 (19)
System\Formats\Asn1\AsnDecoder.Integer.cs (6)
99
public static
BigInteger
ReadInteger(
108
BigInteger
value = new BigInteger(contents, isBigEndian: true);
584
public
BigInteger
ReadInteger(Asn1Tag? expectedTag = null)
586
BigInteger
ret = AsnDecoder.ReadInteger(_data.Span, RuleSet, out int consumed, expectedTag);
814
public
BigInteger
ReadInteger(Asn1Tag? expectedTag = null)
816
BigInteger
ret = AsnDecoder.ReadInteger(_data, RuleSet, out int consumed, expectedTag);
System\Formats\Asn1\AsnDecoder.Oid.cs (3)
83
out
BigInteger
? largeValue)
252
ReadSubIdentifier(contents, out int bytesRead, out long? smallValue, out
BigInteger
? largeValue);
289
BigInteger
firstIdentifier = largeValue.Value;
System\Formats\Asn1\AsnWriter.Integer.cs (2)
60
public void WriteInteger(
BigInteger
value, Asn1Tag? tag = null)
279
private void WriteIntegerCore(Asn1Tag tag,
BigInteger
value)
System\Formats\Asn1\AsnWriter.Oid.cs (8)
116
BigInteger
subIdentifier = ParseSubIdentifier(ref remaining);
147
private static
BigInteger
ParseSubIdentifier(ref ReadOnlySpan<char> oidValue)
160
BigInteger
value =
BigInteger
.Zero;
188
private static int EncodeSubIdentifier(Span<byte> dest, ref
BigInteger
subIdentifier)
198
BigInteger
unencoded = subIdentifier;
203
BigInteger
cur = unencoded & 0x7F;
215
while (unencoded !=
BigInteger
.Zero);
System.Formats.Cbor (7)
System\Formats\Cbor\CborHelpers.netcoreapp.cs (2)
12
public static
BigInteger
CreateBigIntegerFromUnsignedBigEndianBytes(byte[] bytes)
15
public static byte[] CreateUnsignedBigEndianBytesFromBigInteger(
BigInteger
value)
System\Formats\Cbor\Reader\CborReader.Tag.cs (2)
161
public
BigInteger
ReadBigInteger()
186
BigInteger
unsignedValue = CborHelpers.CreateBigIntegerFromUnsignedBigEndianBytes(unsignedBigEndianEncoding);
System\Formats\Cbor\Writer\CborWriter.Tag.cs (3)
88
public void WriteBigInteger(
BigInteger
value)
91
BigInteger
unsignedValue = isUnsigned ? value : -1 - value;
127
WriteBigInteger((
BigInteger
)mantissa);
System.Numerics (1)
System.Numerics.cs (1)
4
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.
BigInteger
))]
System.Runtime.Numerics (536)
System\Number.BigInteger.cs (32)
58
internal static ParsingStatus TryParseBigInteger<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info, out
BigInteger
result, out int elementsConsumed)
72
internal static ParsingStatus TryParseBigIntegerPartial<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info, out
BigInteger
result, out int elementsConsumed)
83
private static ParsingStatus TryParseBigIntegerCore<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info, out
BigInteger
result, out int elementsConsumed)
99
internal static ParsingStatus TryParseBigIntegerNumber<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info, out
BigInteger
result, out int elementsConsumed)
147
internal static
BigInteger
ParseBigInteger<TChar>(ReadOnlySpan<TChar> value, NumberStyles style, NumberFormatInfo info)
155
ParsingStatus status = TryParseBigIntegerCore(value, style, info, out
BigInteger
result, out _);
164
internal static ParsingStatus TryParseBigIntegerHexOrBinaryNumberStyle<TParser, TChar>(ReadOnlySpan<TChar> value, NumberStyles style, out
BigInteger
result, out int elementsConsumed)
292
if (totalUIntCount >
BigInteger
.MaxLength)
321
if (bits.Length + 1 >
BigInteger
.MaxLength)
373
private static ParsingStatus NumberToBigInteger(ref NumberBuffer number, out
BigInteger
result)
420
base1E9 =
BigInteger
.RentedBuffer.Create(base1E9Length, out
BigInteger
.RentedBuffer base1E9Rental);
445
Span<nuint> resultBuffer =
BigInteger
.RentedBuffer.Create(resultLength, out
BigInteger
.RentedBuffer resultRental);
477
Span<nuint> leading =
BigInteger
.RentedBuffer.Create(leadingLength, out
BigInteger
.RentedBuffer leadingBuffer);
517
scoped Span<nuint> buffer =
BigInteger
.RentedBuffer.Create(bufferLength, out
BigInteger
.RentedBuffer bufferRental);
616
private static string? FormatBigIntegerToHex<TChar>(bool targetSpan,
BigInteger
value, char format, int digits, NumberFormatInfo info, Span<TChar> destination, out int charsWritten, out bool spanSuccess)
702
private static string? FormatBigIntegerToBinary<TChar>(bool targetSpan,
BigInteger
value, int digits, Span<TChar> destination, out int charsWritten, out bool spanSuccess)
805
internal static string FormatBigInteger(
BigInteger
value, string? format, NumberFormatInfo info)
810
internal static bool TryFormatBigInteger<TChar>(
BigInteger
value, ReadOnlySpan<char> format, NumberFormatInfo info, Span<TChar> destination, out int charsWritten)
817
private static string? FormatBigInteger<TChar>(bool targetSpan,
BigInteger
value, string? formatString, ReadOnlySpan<char> formatSpan, NumberFormatInfo info, Span<TChar> destination, out int charsWritten, out bool spanSuccess)
869
Debug.Assert(
BigInteger
.MaxLength * digitRatio + 1 < Array.MaxLength); // won't overflow
872
Span<nuint> base1E9Buffer =
BigInteger
.RentedBuffer.Create(base1E9BufferLength, out
BigInteger
.RentedBuffer base1E9Rental);
1077
Span<nuint> upper =
BigInteger
.RentedBuffer.Create(upperLength, out
BigInteger
.RentedBuffer upperBuffer);
1080
Span<nuint> lower =
BigInteger
.RentedBuffer.Create(lowerLength, out
BigInteger
.RentedBuffer lowerBuffer);
1484
Span<nuint> powersOfTen =
BigInteger
.RentedBuffer.Create(bits.Length, out
BigInteger
.RentedBuffer powersOfTenBuffer);
System\Numerics\BigInteger.cs (413)
20
IComparable<
BigInteger
>,
21
IEquatable<
BigInteger
>,
22
IBinaryInteger<
BigInteger
>,
23
ISignedNumber<
BigInteger
>,
39
/// Maximum number of limbs in a <see cref="
BigInteger
"/>. Restricts allocations to ~256MB,
63
private static readonly
BigInteger
s_int32MinValue = new(-1, [UInt32HighBit]);
64
private static readonly
BigInteger
s_one = new(1);
65
private static readonly
BigInteger
s_zero = new(0);
66
private static readonly
BigInteger
s_minusOne = new(-1);
693
/// Initializes a new <see cref="
BigInteger
"/> from serialized data.
729
/// Populates a <see cref="SerializationInfo"/> with the data needed to serialize the <see cref="
BigInteger
"/>.
769
public static
BigInteger
Zero => s_zero;
771
public static
BigInteger
One => s_one;
773
public static
BigInteger
MinusOne => s_minusOne;
802
public static
BigInteger
Parse(string value)
807
public static
BigInteger
Parse(string value, NumberStyles style)
812
public static
BigInteger
Parse(string value, IFormatProvider? provider)
817
public static
BigInteger
Parse(string value, NumberStyles style, IFormatProvider? provider)
823
public static bool TryParse([NotNullWhen(true)] string? value, out
BigInteger
result)
828
public static bool TryParse([NotNullWhen(true)] string? value, NumberStyles style, IFormatProvider? provider, out
BigInteger
result)
833
public static
BigInteger
Parse(ReadOnlySpan<char> value, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
838
public static
BigInteger
Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
843
public static bool TryParse(ReadOnlySpan<char> value, out
BigInteger
result)
848
public static bool TryParse(ReadOnlySpan<char> value, NumberStyles style, IFormatProvider? provider, out
BigInteger
result)
853
public static bool TryParse(ReadOnlySpan<byte> utf8Text, out
BigInteger
result)
858
public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out
BigInteger
result)
864
public static bool TryParsePartial([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out
BigInteger
result, out int charsConsumed)
870
public static bool TryParsePartial(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out
BigInteger
result, out int bytesConsumed)
876
public static bool TryParsePartial(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out
BigInteger
result, out int charsConsumed)
881
public static int Compare(
BigInteger
left,
BigInteger
right)
886
public static
BigInteger
Abs(
BigInteger
value)
891
public static
BigInteger
Add(
BigInteger
left,
BigInteger
right)
896
public static
BigInteger
Subtract(
BigInteger
left,
BigInteger
right)
901
public static
BigInteger
Multiply(
BigInteger
left,
BigInteger
right)
906
public static
BigInteger
Divide(
BigInteger
dividend,
BigInteger
divisor)
911
public static
BigInteger
Remainder(
BigInteger
dividend,
BigInteger
divisor)
916
public static
BigInteger
DivRem(
BigInteger
dividend,
BigInteger
divisor, out
BigInteger
remainder)
923
BigInteger
quotient;
956
BigInteger
quotient = DivideByPowerOfTwo(dividend, divisor, powerOfTwoExponent);
991
BigInteger
result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
1000
public static
BigInteger
Negate(
BigInteger
value)
1005
public static double Log(
BigInteger
value)
1010
public static double Log(
BigInteger
value, double baseValue)
1067
public static double Log10(
BigInteger
value)
1072
public static
BigInteger
GreatestCommonDivisor(
BigInteger
left,
BigInteger
right)
1123
private static
BigInteger
GreatestCommonDivisor(nuint[] leftBits, nuint[] rightBits)
1136
private static
BigInteger
GreatestCommonDivisor(ReadOnlySpan<nuint> leftBits, ReadOnlySpan<nuint> rightBits, int resultOffset)
1140
BigInteger
result;
1179
public static
BigInteger
Max(
BigInteger
left,
BigInteger
right)
1184
public static
BigInteger
Min(
BigInteger
left,
BigInteger
right)
1190
private static bool TryGetPowerOfTwoExponent(
BigInteger
value, out int exponent)
1237
private static
BigInteger
CreatePowerOfTwo(int exponent, bool negative)
1239
BigInteger
result = s_one << exponent;
1243
private static
BigInteger
DivideByPowerOfTwo(
BigInteger
dividend,
BigInteger
divisor, int exponent)
1246
BigInteger
magnitude = dividend._sign < 0 ? -dividend : dividend;
1247
BigInteger
quotient = magnitude >> exponent;
1251
private static
BigInteger
RemainderByPowerOfTwo(
BigInteger
dividend, int exponent)
1278
BigInteger
remainder = new(bits, dividend._sign < 0);
1302
public static
BigInteger
ModPow(
BigInteger
value,
BigInteger
exponent,
BigInteger
modulus)
1338
BigInteger
result;
1381
public static
BigInteger
Pow(
BigInteger
value, int exponent)
1409
BigInteger
result;
1521
BigInteger
exactPower = exactBits.Length == 1 && exactBits[0] <= int.MaxValue
1691
return obj is
BigInteger
other && Equals(other);
1754
public bool Equals(
BigInteger
other)
1826
public int CompareTo(
BigInteger
other)
1857
obj is
BigInteger
bigInt ? CompareTo(bigInt) :
2332
private static
BigInteger
Add(ReadOnlySpan<nuint> leftBits, int leftSign, ReadOnlySpan<nuint> rightBits, int rightSign)
2343
&& TryAddWithCommonLimbOffset(leftBits, leftSign, rightBits, out
BigInteger
fastResult))
2348
BigInteger
result;
2398
public static
BigInteger
operator -(
BigInteger
left,
BigInteger
right)
2410
private static
BigInteger
Subtract(ReadOnlySpan<nuint> leftBits, int leftSign, ReadOnlySpan<nuint> rightBits, int rightSign)
2421
&& TrySubtractWithCommonLimbOffset(leftBits, leftSign, rightBits, out
BigInteger
fastResult))
2426
BigInteger
result;
2478
out
BigInteger
result)
2511
out
BigInteger
result)
2539
public static explicit operator byte(
BigInteger
value) => checked((byte)((int)value));
2544
public static explicit operator char(
BigInteger
value) => checked((char)((int)value));
2546
public static explicit operator decimal(
BigInteger
value)
2556
public static explicit operator double(
BigInteger
value)
2587
private static double ConvertToDouble(
BigInteger
value, int precision)
2723
public static explicit operator Half(
BigInteger
value)
2742
public static explicit operator BFloat16(
BigInteger
value)
2764
public static explicit operator short(
BigInteger
value) => checked((short)((int)value));
2766
public static explicit operator int(
BigInteger
value)
2793
public static explicit operator long(
BigInteger
value)
2833
public static explicit operator Int128(
BigInteger
value)
2882
public static explicit operator nint(
BigInteger
value) => Environment.Is64BitProcess ? (nint)(long)value : (int)value;
2885
public static explicit operator sbyte(
BigInteger
value) => checked((sbyte)((int)value));
2887
public static explicit operator float(
BigInteger
value)
2915
public static explicit operator ushort(
BigInteger
value) => checked((ushort)((int)value));
2918
public static explicit operator uint(
BigInteger
value)
2933
public static explicit operator ulong(
BigInteger
value)
2961
public static explicit operator UInt128(
BigInteger
value)
3001
public static explicit operator nuint(
BigInteger
value) => Environment.Is64BitProcess ? (nuint)(ulong)value : (uint)value;
3007
public static explicit operator
BigInteger
(decimal value) => new BigInteger(value);
3009
public static explicit operator
BigInteger
(double value) => new BigInteger(value);
3014
public static explicit operator
BigInteger
(Half value) => new BigInteger((float)value);
3019
public static explicit operator
BigInteger
(BFloat16 value) => new BigInteger((float)value);
3024
public static explicit operator
BigInteger
(Complex value)
3031
return (
BigInteger
)value.Real;
3034
public static explicit operator
BigInteger
(float value) => new BigInteger(value);
3040
public static implicit operator
BigInteger
(byte value) => new BigInteger(value);
3045
public static implicit operator
BigInteger
(char value) => new BigInteger(value);
3047
public static implicit operator
BigInteger
(short value) => new BigInteger(value);
3049
public static implicit operator
BigInteger
(int value) => new BigInteger(value);
3051
public static implicit operator
BigInteger
(long value) => new BigInteger(value);
3056
public static implicit operator
BigInteger
(Int128 value)
3124
public static implicit operator
BigInteger
(nint value) => new BigInteger(value);
3127
public static implicit operator
BigInteger
(sbyte value) => new BigInteger(value);
3130
public static implicit operator
BigInteger
(ushort value) => new BigInteger(value);
3133
public static implicit operator
BigInteger
(uint value) => new BigInteger(value);
3136
public static implicit operator
BigInteger
(ulong value) => new BigInteger(value);
3142
public static implicit operator
BigInteger
(UInt128 value)
3194
public static implicit operator
BigInteger
(nuint value) => value <= int.MaxValue ? new BigInteger((int)value, null) : new BigInteger(+1, [value]);
3196
public static
BigInteger
operator &(
BigInteger
left,
BigInteger
right) =>
3198
left._bits is null && right._bits is null ? (
BigInteger
)(left._sign & right._sign) :
3201
public static
BigInteger
operator |(
BigInteger
left,
BigInteger
right)
3214
? (
BigInteger
)(left._sign | right._sign)
3218
public static
BigInteger
operator ^(
BigInteger
left,
BigInteger
right) =>
3220
? (
BigInteger
)(left._sign ^ right._sign)
3227
private static
BigInteger
BitwiseAnd(ref readonly
BigInteger
left, ref readonly
BigInteger
right)
3246
private static
BigInteger
BitwiseOr(ref readonly
BigInteger
left, ref readonly
BigInteger
right)
3256
private static
BigInteger
BitwiseXor(ref readonly
BigInteger
left, ref readonly
BigInteger
right)
3263
private static
BigInteger
BitwiseOp<TOp>(ref readonly
BigInteger
left, ref readonly
BigInteger
right, int zLen)
3273
BigInteger
result = new(z);
3280
public static
BigInteger
operator <<(
BigInteger
value, int shift)
3348
private static
BigInteger
LeftShift(int value, int digitShift, int smallShift)
3394
public static
BigInteger
operator >>(
BigInteger
value, int shift)
3455
BigInteger
result = new(zd, neg);
3462
public static
BigInteger
operator ~(
BigInteger
value)
3471
BigInteger
result;
3496
public static
BigInteger
operator -(
BigInteger
value) => new BigInteger(-value._sign, value._bits);
3498
public static
BigInteger
operator +(
BigInteger
value) => value;
3500
public static
BigInteger
operator ++(
BigInteger
value)
3507
BigInteger
result;
3530
public static
BigInteger
operator --(
BigInteger
value)
3537
BigInteger
result;
3560
public static
BigInteger
operator +(
BigInteger
left,
BigInteger
right)
3572
public static
BigInteger
operator *(
BigInteger
left,
BigInteger
right)
3576
return (
BigInteger
)((long)left._sign * right._sign);
3581
BigInteger
result = right << exponent;
3587
BigInteger
result = left << exponent;
3594
private static
BigInteger
Multiply(ReadOnlySpan<nuint> left, int leftSign, ReadOnlySpan<nuint> right, int rightSign)
3601
BigInteger
result;
3649
public static
BigInteger
operator /(
BigInteger
dividend,
BigInteger
divisor)
3676
BigInteger
result = new BigInteger(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3713
BigInteger
result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0));
3721
public static
BigInteger
operator %(
BigInteger
dividend,
BigInteger
divisor)
3775
BigInteger
result = new(bits, dividend._sign < 0);
3785
public static bool operator <(
BigInteger
left,
BigInteger
right) => left.CompareTo(right) < 0;
3787
public static bool operator <=(
BigInteger
left,
BigInteger
right) => left.CompareTo(right) <= 0;
3789
public static bool operator >(
BigInteger
left,
BigInteger
right) => left.CompareTo(right) > 0;
3791
public static bool operator >=(
BigInteger
left,
BigInteger
right) => left.CompareTo(right) >= 0;
3793
public static bool operator ==(
BigInteger
left,
BigInteger
right) => left.Equals(right);
3795
public static bool operator !=(
BigInteger
left,
BigInteger
right) => !left.Equals(right);
3797
public static bool operator <(
BigInteger
left, long right) => left.CompareTo(right) < 0;
3799
public static bool operator <=(
BigInteger
left, long right) => left.CompareTo(right) <= 0;
3801
public static bool operator >(
BigInteger
left, long right) => left.CompareTo(right) > 0;
3803
public static bool operator >=(
BigInteger
left, long right) => left.CompareTo(right) >= 0;
3805
public static bool operator ==(
BigInteger
left, long right) => left.Equals(right);
3807
public static bool operator !=(
BigInteger
left, long right) => !left.Equals(right);
3809
public static bool operator <(long left,
BigInteger
right) => right.CompareTo(left) > 0;
3811
public static bool operator <=(long left,
BigInteger
right) => right.CompareTo(left) >= 0;
3813
public static bool operator >(long left,
BigInteger
right) => right.CompareTo(left) < 0;
3815
public static bool operator >=(long left,
BigInteger
right) => right.CompareTo(left) <= 0;
3817
public static bool operator ==(long left,
BigInteger
right) => right.Equals(left);
3819
public static bool operator !=(long left,
BigInteger
right) => !right.Equals(left);
3822
public static bool operator <(
BigInteger
left, ulong right) => left.CompareTo(right) < 0;
3825
public static bool operator <=(
BigInteger
left, ulong right) => left.CompareTo(right) <= 0;
3828
public static bool operator >(
BigInteger
left, ulong right) => left.CompareTo(right) > 0;
3831
public static bool operator >=(
BigInteger
left, ulong right) => left.CompareTo(right) >= 0;
3834
public static bool operator ==(
BigInteger
left, ulong right) => left.Equals(right);
3837
public static bool operator !=(
BigInteger
left, ulong right) => !left.Equals(right);
3840
public static bool operator <(ulong left,
BigInteger
right) => right.CompareTo(left) > 0;
3843
public static bool operator <=(ulong left,
BigInteger
right) => right.CompareTo(left) >= 0;
3846
public static bool operator >(ulong left,
BigInteger
right) => right.CompareTo(left) < 0;
3849
public static bool operator >=(ulong left,
BigInteger
right) => right.CompareTo(left) <= 0;
3852
public static bool operator ==(ulong left,
BigInteger
right) => right.Equals(left);
3855
public static bool operator !=(ulong left,
BigInteger
right) => !right.Equals(left);
3928
static
BigInteger
IAdditiveIdentity<
BigInteger
,
BigInteger
>.AdditiveIdentity => Zero;
3935
static
BigInteger
IBinaryInteger<
BigInteger
>.Log10(
BigInteger
value)
3957
BigInteger
log2Value = Log2(value);
3958
BigInteger
approx = ((log2Value + 1) * 1292913986L) >> 32;
3959
BigInteger
power = Pow(10, (int)approx);
3965
public static (
BigInteger
Quotient,
BigInteger
Remainder) DivRem(
BigInteger
left,
BigInteger
right)
3967
BigInteger
quotient = DivRem(left, right, out
BigInteger
remainder);
3972
public static
BigInteger
LeadingZeroCount(
BigInteger
value)
3994
public static
BigInteger
PopCount(
BigInteger
value)
4049
public static
BigInteger
RotateLeft(
BigInteger
value, int rotateAmount)
4070
public static
BigInteger
RotateRight(
BigInteger
value, int rotateAmount)
4090
private static
BigInteger
Rotate(ReadOnlySpan<nuint> bits, bool negative, long rotateLeftAmount)
4277
BigInteger
result = new(zd, negative);
4302
private static
BigInteger
RotateNuint(ReadOnlySpan<nuint> bits, bool negative, long rotateLeftAmount)
4339
BigInteger
result = new(zd, negative);
4347
public static
BigInteger
TrailingZeroCount(
BigInteger
value)
4352
private static int GetTrailingZeroCount(
BigInteger
value)
4376
static bool IBinaryInteger<
BigInteger
>.TryReadBigEndian(ReadOnlySpan<byte> source, bool isUnsigned, out
BigInteger
value)
4383
static bool IBinaryInteger<
BigInteger
>.TryReadLittleEndian(ReadOnlySpan<byte> source, bool isUnsigned, out
BigInteger
value)
4390
int IBinaryInteger<
BigInteger
>.GetShortestBitLength()
4427
int IBinaryInteger<
BigInteger
>.GetByteCount() => GetGenericMathByteCount();
4430
bool IBinaryInteger<
BigInteger
>.TryWriteBigEndian(Span<byte> destination, out int bytesWritten)
4508
bool IBinaryInteger<
BigInteger
>.TryWriteLittleEndian(Span<byte> destination, out int bytesWritten)
4623
static
BigInteger
IBinaryNumber<
BigInteger
>.AllBitsSet => MinusOne;
4626
public static bool IsPow2(
BigInteger
value) => value.IsPowerOfTwo;
4629
public static
BigInteger
Log2(
BigInteger
value)
4637
? (
BigInteger
)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1))
4638
: (
BigInteger
)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1]));
4646
static
BigInteger
IMultiplicativeIdentity<
BigInteger
,
BigInteger
>.MultiplicativeIdentity => One;
4653
public static
BigInteger
Clamp(
BigInteger
value,
BigInteger
min,
BigInteger
max)
4679
public static
BigInteger
CopySign(
BigInteger
value,
BigInteger
sign)
4699
static
BigInteger
INumber<
BigInteger
>.MaxNumber(
BigInteger
x,
BigInteger
y) => Max(x, y);
4702
static
BigInteger
INumber<
BigInteger
>.MinNumber(
BigInteger
x,
BigInteger
y) => Min(x, y);
4705
static int INumber<
BigInteger
>.Sign(
BigInteger
value)
4717
static int INumberBase<
BigInteger
>.Radix => 2;
4721
public static
BigInteger
CreateChecked<TOther>(TOther value)
4724
BigInteger
result;
4726
if (typeof(TOther) == typeof(
BigInteger
))
4728
result = (
BigInteger
)(object)value;
4740
public static
BigInteger
CreateSaturating<TOther>(TOther value)
4743
BigInteger
result;
4745
if (typeof(TOther) == typeof(
BigInteger
))
4747
result = (
BigInteger
)(object)value;
4759
public static
BigInteger
CreateTruncating<TOther>(TOther value)
4762
BigInteger
result;
4764
if (typeof(TOther) == typeof(
BigInteger
))
4766
result = (
BigInteger
)(object)value;
4777
static bool INumberBase<
BigInteger
>.IsCanonical(
BigInteger
value) => true;
4780
static bool INumberBase<
BigInteger
>.IsComplexNumber(
BigInteger
value) => false;
4783
public static bool IsEvenInteger(
BigInteger
value)
4791
static bool INumberBase<
BigInteger
>.IsFinite(
BigInteger
value) => true;
4794
static bool INumberBase<
BigInteger
>.IsImaginaryNumber(
BigInteger
value) => false;
4797
static bool INumberBase<
BigInteger
>.IsInfinity(
BigInteger
value) => false;
4800
static bool INumberBase<
BigInteger
>.IsInteger(
BigInteger
value) => true;
4803
static bool INumberBase<
BigInteger
>.IsNaN(
BigInteger
value) => false;
4806
public static bool IsNegative(
BigInteger
value)
4812
static bool INumberBase<
BigInteger
>.IsNegativeInfinity(
BigInteger
value) => false;
4815
static bool INumberBase<
BigInteger
>.IsNormal(
BigInteger
value) => (value != 0);
4818
public static bool IsOddInteger(
BigInteger
value)
4826
public static bool IsPositive(
BigInteger
value)
4832
static bool INumberBase<
BigInteger
>.IsPositiveInfinity(
BigInteger
value) => false;
4835
static bool INumberBase<
BigInteger
>.IsRealNumber(
BigInteger
value) => true;
4838
static bool INumberBase<
BigInteger
>.IsSubnormal(
BigInteger
value) => false;
4841
static bool INumberBase<
BigInteger
>.IsZero(
BigInteger
value)
4847
public static
BigInteger
MaxMagnitude(
BigInteger
x,
BigInteger
y)
4854
static
BigInteger
INumberBase<
BigInteger
>.MaxMagnitudeNumber(
BigInteger
x,
BigInteger
y) => MaxMagnitude(x, y);
4857
public static
BigInteger
MinMagnitude(
BigInteger
x,
BigInteger
y)
4864
static
BigInteger
INumberBase<
BigInteger
>.MinMagnitudeNumber(
BigInteger
x,
BigInteger
y) => MinMagnitude(x, y);
4867
static
BigInteger
INumberBase<
BigInteger
>.MultiplyAddEstimate(
BigInteger
left,
BigInteger
right,
BigInteger
addend) => (left * right) + addend;
4871
static bool INumberBase<
BigInteger
>.TryConvertFromChecked<TOther>(TOther value, out
BigInteger
result) => TryConvertFromChecked(value, out result);
4874
private static bool TryConvertFromChecked<TOther>(TOther value, out
BigInteger
result)
4892
result = (
BigInteger
)actualValue;
4898
result = checked((
BigInteger
)actualValue);
4904
result = checked((
BigInteger
)actualValue);
4910
result = checked((
BigInteger
)actualValue);
4952
result = checked((
BigInteger
)actualValue);
4994
static bool INumberBase<
BigInteger
>.TryConvertFromSaturating<TOther>(TOther value, out
BigInteger
result) => TryConvertFromSaturating(value, out result);
4997
private static bool TryConvertFromSaturating<TOther>(TOther value, out
BigInteger
result)
5015
result = (
BigInteger
)actualValue;
5021
result = double.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5027
result = Half.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5033
result = BFloat16.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5075
result = float.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5117
static bool INumberBase<
BigInteger
>.TryConvertFromTruncating<TOther>(TOther value, out
BigInteger
result) => TryConvertFromTruncating(value, out result);
5120
private static bool TryConvertFromTruncating<TOther>(TOther value, out
BigInteger
result)
5138
result = (
BigInteger
)actualValue;
5144
result = double.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5150
result = Half.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5156
result = BFloat16.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5198
result = float.IsNaN(actualValue) ? Zero : (
BigInteger
)actualValue;
5240
static bool INumberBase<
BigInteger
>.TryConvertToChecked<TOther>(
BigInteger
value, [MaybeNullWhen(false)] out TOther result)
5365
static bool INumberBase<
BigInteger
>.TryConvertToSaturating<TOther>(
BigInteger
value, [MaybeNullWhen(false)] out TOther result)
5564
static bool INumberBase<
BigInteger
>.TryConvertToTruncating<TOther>(
BigInteger
value, [MaybeNullWhen(false)] out TOther result)
5995
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out
BigInteger
result) => TryParse(s, NumberStyles.Integer, provider, out result);
6002
public static
BigInteger
operator >>>(
BigInteger
value, int shiftAmount)
6111
BigInteger
result;
6138
static
BigInteger
ISignedNumber<
BigInteger
>.NegativeOne => MinusOne;
6145
public static
BigInteger
Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, NumberStyles.Integer, provider);
6148
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out
BigInteger
result) => TryParse(s, NumberStyles.Integer, provider, out result);
6155
public static
BigInteger
Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, NumberStyles.Integer, provider);
6158
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out
BigInteger
result) => TryParse(utf8Text, NumberStyles.Integer, provider, out result);
System\Numerics\BigInteger.RentedBuffer.cs (1)
14
/// Provides temporary buffer management for <see cref="
BigInteger
"/> operations, using either stack-allocated inline storage or pooled arrays depending on size requirements.
System\Numerics\BigIntegerCalculator.DivRem.cs (28)
49
Span<nuint> leftCopy =
BigInteger
.RentedBuffer.Create(left.Length, out
BigInteger
.RentedBuffer leftCopyBuffer);
79
Span<nuint> quotient =
BigInteger
.RentedBuffer.Create(quotientLength, out
BigInteger
.RentedBuffer quotientBuffer);
150
Span<nuint> leftCopy =
BigInteger
.RentedBuffer.Create(
151
left.Length, out
BigInteger
.RentedBuffer leftCopyBuffer);
239
Span<nuint> leftCopy =
BigInteger
.RentedBuffer.Create(left.Length, out
BigInteger
.RentedBuffer leftCopyBuffer);
243
Span<nuint> quotientAllocated =
BigInteger
.RentedBuffer.Create(quotientLength, out
BigInteger
.RentedBuffer quotientActualBuffer);
288
Span<nuint> rented =
BigInteger
.RentedBuffer.Create(rentedLength, out
BigInteger
.RentedBuffer sumBuffer);
448
Span<nuint> b =
BigInteger
.RentedBuffer.Create(n, out
BigInteger
.RentedBuffer bBuffer);
461
Span<nuint> a =
BigInteger
.RentedBuffer.Create(aLength, out
BigInteger
.RentedBuffer aBuffer);
497
Span<nuint> r =
BigInteger
.RentedBuffer.Create(n + 1, out
BigInteger
.RentedBuffer rBuffer);
499
Span<nuint> z =
BigInteger
.RentedBuffer.Create(2 * n, out
BigInteger
.RentedBuffer zBuffer);
506
Span<nuint> q =
BigInteger
.RentedBuffer.Create(n, out
BigInteger
.RentedBuffer qBuffer);
613
Span<nuint> r1 =
BigInteger
.RentedBuffer.Create(left.Length, out
BigInteger
.RentedBuffer r1Buffer);
653
Span<nuint> r1 =
BigInteger
.RentedBuffer.Create(right.Length + 1, out
BigInteger
.RentedBuffer r1Buffer);
678
Span<nuint> d =
BigInteger
.RentedBuffer.Create(right.Length, out
BigInteger
.RentedBuffer dBuffer);
System\Numerics\BigIntegerCalculator.GcdInv.cs (2)
112
Span<nuint> rightCopy =
BigInteger
.RentedBuffer.Create(right.Length, out
BigInteger
.RentedBuffer rightCopyBuffer);
System\Numerics\BigIntegerCalculator.PowMod.cs (34)
25
Span<nuint> temp =
BigInteger
.RentedBuffer.Create(bits.Length, out
BigInteger
.RentedBuffer tempBuffer);
27
Span<nuint> valueCopy =
BigInteger
.RentedBuffer.Create(bits.Length, out
BigInteger
.RentedBuffer valueCopyBuffer);
64
Span<nuint> temp =
BigInteger
.RentedBuffer.Create(bits.Length, out
BigInteger
.RentedBuffer tempBuffer);
74
Span<nuint> continuationPower =
BigInteger
.RentedBuffer.Create(
75
bits.Length, out
BigInteger
.RentedBuffer continuationPowerBuffer);
439
Span<nuint> valueCopy =
BigInteger
.RentedBuffer.Create(size, out
BigInteger
.RentedBuffer valueCopyBuffer);
455
Span<nuint> temp =
BigInteger
.RentedBuffer.Create(bits.Length, out
BigInteger
.RentedBuffer tempBuffer);
479
Span<nuint> valueCopy =
BigInteger
.RentedBuffer.Create(size, out
BigInteger
.RentedBuffer valueCopyBuffer);
495
Span<nuint> temp =
BigInteger
.RentedBuffer.Create(bits.Length, out
BigInteger
.RentedBuffer tempBuffer);
564
Span<nuint> r =
BigInteger
.RentedBuffer.Create(size, out
BigInteger
.RentedBuffer rBuffer);
567
Span<nuint> mu =
BigInteger
.RentedBuffer.Create(size, out
BigInteger
.RentedBuffer muBuffer);
570
Span<nuint> q1 =
BigInteger
.RentedBuffer.Create(size, out
BigInteger
.RentedBuffer q1Buffer);
572
Span<nuint> q2 =
BigInteger
.RentedBuffer.Create(size, out
BigInteger
.RentedBuffer q2Buffer);
668
Span<nuint> shifted =
BigInteger
.RentedBuffer.Create(shiftLen, out
BigInteger
.RentedBuffer shiftedBuffer);
683
Span<nuint> rModN =
BigInteger
.RentedBuffer.Create(k, out
BigInteger
.RentedBuffer rModNBuffer);
686
Span<nuint> oneShifted =
BigInteger
.RentedBuffer.Create(oneShiftLen, out
BigInteger
.RentedBuffer oneShiftedBuffer);
735
Span<nuint> prod =
BigInteger
.RentedBuffer.Create(bufLen, out
BigInteger
.RentedBuffer prodBuffer);
738
Span<nuint> base2 =
BigInteger
.RentedBuffer.Create(k, out
BigInteger
.RentedBuffer base2Buffer);
System\Numerics\BigIntegerCalculator.ShiftRot.cs (4)
84
Span<nuint> tmp =
BigInteger
.RentedBuffer.Create(tmpLength, out
BigInteger
.RentedBuffer tmpBuffer);
121
Span<nuint> tmpNuint =
BigInteger
.RentedBuffer.Create(nuintCount, out
BigInteger
.RentedBuffer tmpBuffer);
System\Numerics\BigIntegerCalculator.SquMul.cs (12)
151
Span<nuint> fold =
BigInteger
.RentedBuffer.Create(foldLength, out
BigInteger
.RentedBuffer foldBuffer);
154
Span<nuint> core =
BigInteger
.RentedBuffer.Create(coreLength, out
BigInteger
.RentedBuffer coreBuffer);
523
Span<nuint> leftFold =
BigInteger
.RentedBuffer.Create(foldLength, out
BigInteger
.RentedBuffer leftFoldBuffer);
525
Span<nuint> rightFold =
BigInteger
.RentedBuffer.Create(foldLength, out
BigInteger
.RentedBuffer rightFoldBuffer);
534
Span<nuint> core =
BigInteger
.RentedBuffer.Create(coreLength, out
BigInteger
.RentedBuffer coreBuffer);
577
Span<nuint> carry =
BigInteger
.RentedBuffer.Create(carryLength, out
BigInteger
.RentedBuffer carryBuffer);
System\Numerics\Complex.cs (1)
368
public static explicit operator Complex(
BigInteger
value)
System\Numerics\Complex.Generic.cs (9)
1797
if (typeof(TOther) == typeof(
BigInteger
))
1804
BigInteger
actualResult = checked((
BigInteger
)double.CreateChecked(value.m_real));
1843
if (typeof(TOther) == typeof(
BigInteger
))
1845
BigInteger
actualResult = (
BigInteger
)double.CreateSaturating(value.m_real);
1874
if (typeof(TOther) == typeof(
BigInteger
))
1876
BigInteger
actualResult = (
BigInteger
)double.CreateTruncating(value.m_real);
System.Security.Cryptography (34)
src\runtime\src\libraries\Common\src\System\Security\Cryptography\DSAKeyFormatHelper.cs (10)
28
BigInteger
x;
52
BigInteger
p = new BigInteger(parms.P, isBigEndian: true);
53
BigInteger
q = new BigInteger(parms.Q, isBigEndian: true);
54
BigInteger
g = new BigInteger(parms.G, isBigEndian: true);
86
BigInteger
y =
BigInteger
.ModPow(g, x, p);
100
BigInteger
y;
121
BigInteger
p = new BigInteger(parms.P, isBigEndian: true);
122
BigInteger
q = new BigInteger(parms.Q, isBigEndian: true);
123
BigInteger
g = new BigInteger(parms.G, isBigEndian: true);
System\Security\Cryptography\KeyBlobHelpers.cs (1)
40
internal static byte[] ExportKeyParameter(this
BigInteger
value, int length)
System\Security\Cryptography\X509Certificates\CertificateRevocationListBuilder.Build.cs (4)
111
BigInteger
crlNumber,
128
BigInteger
crlNumber,
310
BigInteger
crlNumber,
329
BigInteger
crlNumber,
System\Security\Cryptography\X509Certificates\CertificateRevocationListBuilder.Load.cs (6)
43
public static CertificateRevocationListBuilder Load(byte[] currentCrl, out
BigInteger
currentCrlNumber)
49
out
BigInteger
crlNumber,
85
out
BigInteger
currentCrlNumber,
89
BigInteger
crlNumber = 0;
231
public static CertificateRevocationListBuilder LoadPem(string currentCrl, out
BigInteger
currentCrlNumber)
266
public static CertificateRevocationListBuilder LoadPem(ReadOnlySpan<char> currentCrl, out
BigInteger
currentCrlNumber)
System\Security\Cryptography\X509Certificates\FindPal.cs (8)
95
BigInteger
hexValue = new BigInteger(hexBytes, isUnsigned: true, isBigEndian: true);
96
BigInteger
decimalValue = LaxParseDecimalBigInteger(decimalOrHexString);
243
private static
BigInteger
LaxParseDecimalBigInteger(string decimalString)
245
BigInteger
ten = new BigInteger(10);
246
BigInteger
accum =
BigInteger
.Zero;
252
accum =
BigInteger
.Multiply(accum, ten);
253
accum =
BigInteger
.Add(accum, c - '0');
System\Security\Cryptography\X509Certificates\FindPal.Windows.cs (3)
90
public unsafe void FindBySerialNumber(
BigInteger
hexValue,
BigInteger
decimalValue)
101
BigInteger
actualAsBigInteger = new BigInteger(actual, isUnsigned: true);
System\Security\Cryptography\X509Certificates\IFindPal.cs (2)
17
void FindBySerialNumber(
BigInteger
hexValue,
BigInteger
decimalValue);
System.Security.Cryptography.Cose (1)
System\Security\Cryptography\Cose\CoseHelpers.cs (1)
183
=> throw new CryptographicException(SR.Format(SR.Sign1UnknownCoseAlgorithm,
BigInteger
.MinusOne - new BigInteger(alg)));
System.Security.Cryptography.Pkcs (1)
System\Security\Cryptography\Pkcs\CmsSignature.cs (1)
244
BigInteger
val = new BigInteger(
System.Security.Cryptography.Xml (3)
System\Security\Cryptography\Xml\KeyInfoX509Data.cs (3)
161
BigInteger
h;
162
if (!
BigInteger
.TryParse(serialNumber, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out h))
167
if (h <
BigInteger
.Zero)