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)
772
if (value.
_bits
== null)
818
int base1E9BufferLength = (int)(value.
_bits
.Length * digitRatio) + 1;
826
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);
2841
bool trivialDividend = dividend.
_bits
== null;
2842
bool trivialDivisor = divisor.
_bits
== null;
2860
Debug.Assert(dividend.
_bits
!= null);
2862
int size = dividend.
_bits
.Length;
2870
BigIntegerCalculator.Divide(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign), quotient);
2880
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2882
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2888
int size = dividend.
_bits
.Length - divisor.
_bits
.Length + 1;
2893
BigIntegerCalculator.Divide(dividend.
_bits
, divisor.
_bits
, quotient);
2908
bool trivialDividend = dividend.
_bits
== null;
2909
bool trivialDivisor = divisor.
_bits
== null;
2925
Debug.Assert(dividend.
_bits
!= null);
2926
uint remainder = BigIntegerCalculator.Remainder(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign));
2930
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2932
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2938
int size = dividend.
_bits
.Length;
2943
BigIntegerCalculator.Remainder(dividend.
_bits
, divisor.
_bits
, bits);
3125
uint[]? bits =
_bits
;
3165
if (
_bits
!= null)
3170
Debug.Assert(
_bits
.Length > 0);
3172
Debug.Assert(
_bits
.Length > 1 ||
_bits
[0] >= kuMaskHighBit);
3174
Debug.Assert(
_bits
[
_bits
.Length - 1] != 0);
3176
Debug.Assert(
_bits
.Length <= MaxLength);
3208
if (value.
_bits
is null)
3216
return (value._sign >= 0) ? uint.LeadingZeroCount(value.
_bits
[^1]) : 0;
3224
if (value.
_bits
is null)
3235
for (int i = 0; i < value.
_bits
.Length; i++)
3237
uint part = value.
_bits
[i];
3253
part = ~value.
_bits
[i] + 1;
3258
while ((part == 0) && (i < value.
_bits
.Length));
3260
while (i < value.
_bits
.Length)
3264
part = ~value.
_bits
[i];
3283
if (value.
_bits
is null)
3291
return Rotate(value.
_bits
, neg, rotateAmount);
3304
if (value.
_bits
is null)
3312
return Rotate(value.
_bits
, neg, -(long)rotateAmount);
3377
if (value.
_bits
is null)
3387
uint part = value.
_bits
[0];
3389
for (int i = 1; (part == 0) && (i < value.
_bits
.Length); i++)
3391
part = value.
_bits
[i];
3418
uint[]? bits =
_bits
;
3470
uint[]? bits =
_bits
;
3572
uint[]? bits =
_bits
;
3672
uint[]? bits =
_bits
;
3729
if (value.
_bits
is null)
3734
return ((value.
_bits
.Length * 32) - 1) ^ uint.LeadingZeroCount(value.
_bits
[^1]);
3787
if (value.
_bits
is null)
3794
if (sign.
_bits
is null)
3813
if (value.
_bits
is null)
3896
if (value.
_bits
is null)
3900
return (value.
_bits
[0] & 1) == 0;
3936
if (value.
_bits
is null)
3940
return (value.
_bits
[0] & 1) != 0;
4497
if (value.
_bits
is not null)
4514
if (value.
_bits
is not null)
4556
if (value.
_bits
is not null)
4573
if (value.
_bits
is not null)
4617
if (value.
_bits
is not null)
4640
if (value.
_bits
is not null)
4696
if (value.
_bits
is not null)
4698
uint bits = value.
_bits
[0];
4719
if (value.
_bits
is not null)
4721
uint bits = value.
_bits
[0];
4767
if (value.
_bits
is not null)
4769
actualResult = IsNegative(value) ? (short)(~value.
_bits
[0] + 1) : (short)value.
_bits
[0];
4783
if (value.
_bits
is not null)
4785
actualResult = IsNegative(value) ? (int)(~value.
_bits
[0] + 1) : (int)value.
_bits
[0];
4799
if (value.
_bits
is not null)
4803
if (value.
_bits
.Length >= 2)
4805
bits = value.
_bits
[1];
4809
bits |= value.
_bits
[0];
4830
if (value.
_bits
is not null)
4835
if (value.
_bits
.Length >= 4)
4837
upperBits = value.
_bits
[3];
4841
if (value.
_bits
.Length >= 3)
4843
upperBits |= value.
_bits
[2];
4846
if (value.
_bits
.Length >= 2)
4848
lowerBits = value.
_bits
[1];
4852
lowerBits |= value.
_bits
[0];
4875
if (value.
_bits
is not null)
4879
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
4881
bits = value.
_bits
[1];
4885
bits |= value.
_bits
[0];
4912
if (value.
_bits
is not null)
4914
actualResult = IsNegative(value) ? (sbyte)(~value.
_bits
[0] + 1) : (sbyte)value.
_bits
[0];
4934
if (value.
_bits
is not null)
4936
uint bits = value.
_bits
[0];
4957
if (value.
_bits
is not null)
4959
uint bits = value.
_bits
[0];
4980
if (value.
_bits
is not null)
4984
if (value.
_bits
.Length >= 2)
4986
bits = value.
_bits
[1];
4990
bits |= value.
_bits
[0];
5011
if (value.
_bits
is not null)
5016
if (value.
_bits
.Length >= 4)
5018
upperBits = value.
_bits
[3];
5022
if (value.
_bits
.Length >= 3)
5024
upperBits |= value.
_bits
[2];
5027
if (value.
_bits
.Length >= 2)
5029
lowerBits = value.
_bits
[1];
5033
lowerBits |= value.
_bits
[0];
5056
if (value.
_bits
is not null)
5060
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
5062
bits = value.
_bits
[1];
5066
bits |= value.
_bits
[0];
5117
if (value.
_bits
is null)
5127
ReadOnlySpan<uint> bits = value.
_bits
;