28 writes to _bits
System.Runtime.Numerics (28)
System\Numerics\BigInteger.cs (28)
59
_bits
= null;
70
_bits
= null;
75
_bits
= new uint[1];
86
_bits
= null;
108
_bits
= new uint[1];
113
_bits
= new uint[2];
128
_bits
= null;
133
_bits
= new uint[1];
139
_bits
= new uint[2];
166
_bits
= null;
213
_bits
= new uint[cu + 2];
246
_bits
= null;
250
_bits
= new uint[size];
323
_bits
= null;
347
_bits
= null;
354
_bits
= new uint[1] { unchecked((uint)_sign) };
448
_bits
= null;
460
_bits
= new uint[len];
466
_bits
= val;
472
_bits
= val;
490
_bits
= bits;
523
_bits
= null;
533
_bits
= [value[0]];
539
_bits
= value.ToArray();
599
_bits
= null;
605
_bits
= [value[0]];
610
_bits
= null;
629
_bits
= value.ToArray();
318 references to _bits
System.Runtime.Numerics (318)
System\Number.BigInteger.cs (3)
769
if (value.
_bits
== null)
815
int base1E9BufferLength = (int)(value.
_bits
.Length * digitRatio) + 1;
823
BigIntegerToBase1E9(value.
_bits
, base1E9Buffer, out int written);
System\Numerics\BigInteger.cs (315)
76
_bits
[0] = value;
109
_bits
[0] = (uint)x;
114
_bits
[0] = unchecked((uint)x);
115
_bits
[1] = (uint)(x >> kcbitUint);
134
_bits
[0] = (uint)value;
140
_bits
[0] = unchecked((uint)value);
141
_bits
[1] = (uint)(value >> kcbitUint);
214
_bits
[cu + 1] = (uint)(man >> (cbit + kcbitUint));
215
_bits
[cu] = unchecked((uint)(man >> cbit));
217
_bits
[cu - 1] = unchecked((uint)man) << (kcbitUint - cbit);
254
_bits
[0] = (uint)bits[0];
256
_bits
[1] = (uint)bits[1];
258
_bits
[2] = (uint)bits[2];
461
Array.Copy(val,
_bits
, len);
646
if (
_bits
== null)
652
int iu =
_bits
.Length - 1;
654
return BitOperations.IsPow2(
_bits
[iu]) && !
_bits
.AsSpan(0, iu).ContainsAnyExcept(0u);
660
public bool IsOne { get { AssertValid(); return _sign == 1 &&
_bits
== null; } }
662
public bool IsEven { get { AssertValid(); return
_bits
== null ? (_sign & 1) == 0 : (
_bits
[0] & 1) == 0; } }
738
return new BigInteger(unchecked((int)NumericsHelpers.Abs(value._sign)), value.
_bits
);
771
bool trivialDividend = dividend.
_bits
== null;
772
bool trivialDivisor = divisor.
_bits
== null;
789
Debug.Assert(dividend.
_bits
!= null);
796
int size = dividend.
_bits
.Length;
804
BigIntegerCalculator.Divide(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign), quotient, out rest);
816
Debug.Assert(divisor.
_bits
!= null);
818
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
826
int size = dividend.
_bits
.Length;
832
size = dividend.
_bits
.Length - divisor.
_bits
.Length + 1;
837
BigIntegerCalculator.Divide(dividend.
_bits
, divisor.
_bits
, quotient, rest);
870
if (value.
_bits
== null)
873
ulong h = value.
_bits
[value.
_bits
.Length - 1];
874
ulong m = value.
_bits
.Length > 1 ? value.
_bits
[value.
_bits
.Length - 2] : 0;
875
ulong l = value.
_bits
.Length > 2 ? value.
_bits
[value.
_bits
.Length - 3] : 0;
879
long b = (long)value.
_bits
.Length * 32 - c;
899
bool trivialLeft = left.
_bits
== null;
900
bool trivialRight = right.
_bits
== null;
909
Debug.Assert(right.
_bits
!= null);
911
? BigIntegerCalculator.Gcd(right.
_bits
, NumericsHelpers.Abs(left._sign))
912
: new BigInteger(right.
_bits
, negative: false);
917
Debug.Assert(left.
_bits
!= null);
919
? BigIntegerCalculator.Gcd(left.
_bits
, NumericsHelpers.Abs(right._sign))
920
: new BigInteger(left.
_bits
, negative: false);
923
Debug.Assert(left.
_bits
!= null && right.
_bits
!= null);
925
if (BigIntegerCalculator.Compare(left.
_bits
, right.
_bits
) < 0)
927
return GreatestCommonDivisor(right.
_bits
, left.
_bits
);
931
return GreatestCommonDivisor(left.
_bits
, right.
_bits
);
999
bool trivialValue = value.
_bits
== null;
1000
bool trivialExponent = exponent.
_bits
== null;
1001
bool trivialModulus = modulus.
_bits
== null;
1008
trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent.
_bits
!, NumericsHelpers.Abs(modulus._sign)) :
1009
trivialExponent ? BigIntegerCalculator.Pow(value.
_bits
!, NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) :
1010
BigIntegerCalculator.Pow(value.
_bits
!, exponent.
_bits
!, NumericsHelpers.Abs(modulus._sign));
1016
int size = (modulus.
_bits
?.Length ?? 1) << 1;
1026
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), modulus.
_bits
!, bits);
1030
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent.
_bits
!, modulus.
_bits
!, bits);
1035
BigIntegerCalculator.Pow(value.
_bits
!, NumericsHelpers.Abs(exponent._sign), modulus.
_bits
!, bits);
1039
BigIntegerCalculator.Pow(value.
_bits
!, exponent.
_bits
!, modulus.
_bits
!, bits);
1062
bool trivialValue = value.
_bits
== null;
1088
int size = BigIntegerCalculator.PowBound(power, value.
_bits
!.Length);
1094
BigIntegerCalculator.Pow(value.
_bits
, power, bits);
1108
if (
_bits
is null)
1112
hash.AddBytes(MemoryMarshal.AsBytes(
_bits
.AsSpan()));
1128
if (
_bits
== null)
1132
if ((_sign ^ other) < 0 || (cu =
_bits
.Length) > 2)
1137
return
_bits
[0] == uu;
1139
return NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) == uu;
1149
if (
_bits
== null)
1152
int cu =
_bits
.Length;
1156
return
_bits
[0] == other;
1157
return NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) == other;
1165
return _sign == other._sign &&
_bits
.AsSpan().SequenceEqual(other.
_bits
);
1172
if (
_bits
== null)
1175
if ((_sign ^ other) < 0 || (cu =
_bits
.Length) > 2)
1178
ulong uuTmp = cu == 2 ? NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) :
_bits
[0];
1189
if (
_bits
== null)
1191
int cu =
_bits
.Length;
1194
ulong uuTmp = cu == 2 ? NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) :
_bits
[0];
1210
if (
_bits
== null)
1212
if (other.
_bits
== null)
1217
if (other.
_bits
== null)
1220
int bitsResult = BigIntegerCalculator.Compare(
_bits
, other.
_bits
);
1380
uint[]? bits =
_bits
;
1564
Debug.Assert(
_bits
is null || _sign == 0 ? buffer.Length == 2 : buffer.Length >=
_bits
.Length + 1);
1568
if (
_bits
is null)
1575
_bits
.CopyTo(buffer);
1576
buffer = buffer.Slice(0,
_bits
.Length + 1);
1640
if ((
_bits
is null) || (
_bits
.Length <= 4))
1650
ulong highBits = ((ulong)
_bits
[^1] << kcbitUint) +
_bits
[^2];
1651
double lowBitsCount32 =
_bits
.Length - 2; // if Length > int.MaxValue/32, counting in bits can cause overflow
1766
if (left.
_bits
== null && right.
_bits
== null)
1770
return Add(left.
_bits
, left._sign, right.
_bits
, -1 * right._sign);
1771
return Subtract(left.
_bits
, left._sign, right.
_bits
, right._sign);
1857
if (value.
_bits
== null)
1860
int length = value.
_bits
.Length;
1867
if (length > 2) hi = (int)value.
_bits
[2];
1868
if (length > 1) mi = (int)value.
_bits
[1];
1869
if (length > 0) lo = (int)value.
_bits
[0];
1880
uint[]? bits = value.
_bits
;
1936
if (value.
_bits
== null)
1940
if (value.
_bits
.Length > 1)
1947
return checked((int)value.
_bits
[0]);
1949
if (value.
_bits
[0] > kuMaskHighBit)
1954
return unchecked(-(int)value.
_bits
[0]);
1960
if (value.
_bits
== null)
1965
int len = value.
_bits
.Length;
1974
uu = NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
1978
uu = value.
_bits
[0];
1997
if (value.
_bits
is null)
2002
int len = value.
_bits
.Length;
2014
NumericsHelpers.MakeUInt64((len > 3) ? value.
_bits
[3] : 0, value.
_bits
[2]),
2015
NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0])
2020
uu = NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2024
uu = value.
_bits
[0];
2073
if (value.
_bits
== null)
2077
else if (value.
_bits
.Length > 1 || value._sign < 0)
2083
return value.
_bits
[0];
2091
if (value.
_bits
== null)
2096
int len = value.
_bits
.Length;
2104
return NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2106
return value.
_bits
[0];
2117
if (value.
_bits
is null)
2122
int len = value.
_bits
.Length;
2132
NumericsHelpers.MakeUInt64((len > 3) ? value.
_bits
[3] : 0, value.
_bits
[2]),
2133
NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0])
2138
return NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2140
return value.
_bits
[0];
2406
if (left.
_bits
is null && right.
_bits
is null)
2415
int size = (left.
_bits
?.Length ?? 1) + 1;
2422
size = (right.
_bits
?.Length ?? 1) + 1;
2462
if (left.
_bits
is null && right.
_bits
is null)
2471
int size = (left.
_bits
?.Length ?? 1) + 1;
2478
size = (right.
_bits
?.Length ?? 1) + 1;
2513
if (left.
_bits
is null && right.
_bits
is null)
2522
int size = (left.
_bits
?.Length ?? 1) + 1;
2529
size = (right.
_bits
?.Length ?? 1) + 1;
2575
if (value.
_bits
is null)
2579
ReadOnlySpan<uint> bits = value.
_bits
;
2657
if (value.
_bits
is null)
2670
ReadOnlySpan<uint> bits = value.
_bits
;
2716
return new BigInteger(-value._sign, value.
_bits
);
2740
if (left.
_bits
== null && right.
_bits
== null)
2744
return Subtract(left.
_bits
, left._sign, right.
_bits
, -1 * right._sign);
2745
return Add(left.
_bits
, left._sign, right.
_bits
, right._sign);
2753
if (left.
_bits
== null && right.
_bits
== null)
2756
return Multiply(left.
_bits
, left._sign, right.
_bits
, right._sign);
2829
bool trivialDividend = dividend.
_bits
== null;
2830
bool trivialDivisor = divisor.
_bits
== null;
2848
Debug.Assert(dividend.
_bits
!= null);
2850
int size = dividend.
_bits
.Length;
2858
BigIntegerCalculator.Divide(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign), quotient);
2868
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2870
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2876
int size = dividend.
_bits
.Length - divisor.
_bits
.Length + 1;
2881
BigIntegerCalculator.Divide(dividend.
_bits
, divisor.
_bits
, quotient);
2896
bool trivialDividend = dividend.
_bits
== null;
2897
bool trivialDivisor = divisor.
_bits
== null;
2913
Debug.Assert(dividend.
_bits
!= null);
2914
uint remainder = BigIntegerCalculator.Remainder(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign));
2918
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2920
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2926
int size = dividend.
_bits
.Length;
2931
BigIntegerCalculator.Remainder(dividend.
_bits
, divisor.
_bits
, bits);
3113
uint[]? bits =
_bits
;
3153
if (
_bits
!= null)
3158
Debug.Assert(
_bits
.Length > 0);
3160
Debug.Assert(
_bits
.Length > 1 ||
_bits
[0] >= kuMaskHighBit);
3162
Debug.Assert(
_bits
[
_bits
.Length - 1] != 0);
3164
Debug.Assert(
_bits
.Length <= MaxLength);
3196
if (value.
_bits
is null)
3204
return (value._sign >= 0) ? uint.LeadingZeroCount(value.
_bits
[^1]) : 0;
3212
if (value.
_bits
is null)
3223
for (int i = 0; i < value.
_bits
.Length; i++)
3225
uint part = value.
_bits
[i];
3241
part = ~value.
_bits
[i] + 1;
3246
while ((part == 0) && (i < value.
_bits
.Length));
3248
while (i < value.
_bits
.Length)
3252
part = ~value.
_bits
[i];
3271
if (value.
_bits
is null)
3279
return Rotate(value.
_bits
, neg, rotateAmount);
3292
if (value.
_bits
is null)
3300
return Rotate(value.
_bits
, neg, -(long)rotateAmount);
3365
if (value.
_bits
is null)
3375
uint part = value.
_bits
[0];
3377
for (int i = 1; (part == 0) && (i < value.
_bits
.Length); i++)
3379
part = value.
_bits
[i];
3406
uint[]? bits =
_bits
;
3458
uint[]? bits =
_bits
;
3560
uint[]? bits =
_bits
;
3660
uint[]? bits =
_bits
;
3717
if (value.
_bits
is null)
3722
return ((value.
_bits
.Length * 32) - 1) ^ uint.LeadingZeroCount(value.
_bits
[^1]);
3775
if (value.
_bits
is null)
3782
if (sign.
_bits
is null)
3801
if (value.
_bits
is null)
3884
if (value.
_bits
is null)
3888
return (value.
_bits
[0] & 1) == 0;
3924
if (value.
_bits
is null)
3928
return (value.
_bits
[0] & 1) != 0;
4485
if (value.
_bits
is not null)
4502
if (value.
_bits
is not null)
4544
if (value.
_bits
is not null)
4561
if (value.
_bits
is not null)
4605
if (value.
_bits
is not null)
4628
if (value.
_bits
is not null)
4684
if (value.
_bits
is not null)
4686
uint bits = value.
_bits
[0];
4707
if (value.
_bits
is not null)
4709
uint bits = value.
_bits
[0];
4755
if (value.
_bits
is not null)
4757
actualResult = IsNegative(value) ? (short)(~value.
_bits
[0] + 1) : (short)value.
_bits
[0];
4771
if (value.
_bits
is not null)
4773
actualResult = IsNegative(value) ? (int)(~value.
_bits
[0] + 1) : (int)value.
_bits
[0];
4787
if (value.
_bits
is not null)
4791
if (value.
_bits
.Length >= 2)
4793
bits = value.
_bits
[1];
4797
bits |= value.
_bits
[0];
4818
if (value.
_bits
is not null)
4823
if (value.
_bits
.Length >= 4)
4825
upperBits = value.
_bits
[3];
4829
if (value.
_bits
.Length >= 3)
4831
upperBits |= value.
_bits
[2];
4834
if (value.
_bits
.Length >= 2)
4836
lowerBits = value.
_bits
[1];
4840
lowerBits |= value.
_bits
[0];
4863
if (value.
_bits
is not null)
4867
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
4869
bits = value.
_bits
[1];
4873
bits |= value.
_bits
[0];
4900
if (value.
_bits
is not null)
4902
actualResult = IsNegative(value) ? (sbyte)(~value.
_bits
[0] + 1) : (sbyte)value.
_bits
[0];
4922
if (value.
_bits
is not null)
4924
uint bits = value.
_bits
[0];
4945
if (value.
_bits
is not null)
4947
uint bits = value.
_bits
[0];
4968
if (value.
_bits
is not null)
4972
if (value.
_bits
.Length >= 2)
4974
bits = value.
_bits
[1];
4978
bits |= value.
_bits
[0];
4999
if (value.
_bits
is not null)
5004
if (value.
_bits
.Length >= 4)
5006
upperBits = value.
_bits
[3];
5010
if (value.
_bits
.Length >= 3)
5012
upperBits |= value.
_bits
[2];
5015
if (value.
_bits
.Length >= 2)
5017
lowerBits = value.
_bits
[1];
5021
lowerBits |= value.
_bits
[0];
5044
if (value.
_bits
is not null)
5048
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
5050
bits = value.
_bits
[1];
5054
bits |= value.
_bits
[0];
5105
if (value.
_bits
is null)
5115
ReadOnlySpan<uint> bits = value.
_bits
;