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;
486
_bits
= rgu;
519
_bits
= null;
529
_bits
= [value[0]];
535
_bits
= value.ToArray();
595
_bits
= null;
601
_bits
= [value[0]];
606
_bits
= null;
625
_bits
= value.ToArray();
319 references to _bits
System.Runtime.Numerics (319)
System\Number.BigInteger.cs (3)
765
if (value.
_bits
== null)
787
int cuSrc = value.
_bits
.Length;
802
uint uCarry = value.
_bits
[iuSrc];
System\Numerics\BigInteger.cs (316)
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);
642
if (
_bits
== null)
648
int iu =
_bits
.Length - 1;
650
return BitOperations.IsPow2(
_bits
[iu]) && !
_bits
.AsSpan(0, iu).ContainsAnyExcept(0u);
656
public bool IsOne { get { AssertValid(); return _sign == 1 &&
_bits
== null; } }
658
public bool IsEven { get { AssertValid(); return
_bits
== null ? (_sign & 1) == 0 : (
_bits
[0] & 1) == 0; } }
751
bool trivialDividend = dividend.
_bits
== null;
752
bool trivialDivisor = divisor.
_bits
== null;
769
Debug.Assert(dividend.
_bits
!= null);
776
int size = dividend.
_bits
.Length;
784
BigIntegerCalculator.Divide(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign), quotient, out rest);
796
Debug.Assert(divisor.
_bits
!= null);
798
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
806
int size = dividend.
_bits
.Length;
812
size = dividend.
_bits
.Length - divisor.
_bits
.Length + 1;
817
BigIntegerCalculator.Divide(dividend.
_bits
, divisor.
_bits
, quotient, rest);
850
if (value.
_bits
== null)
853
ulong h = value.
_bits
[value.
_bits
.Length - 1];
854
ulong m = value.
_bits
.Length > 1 ? value.
_bits
[value.
_bits
.Length - 2] : 0;
855
ulong l = value.
_bits
.Length > 2 ? value.
_bits
[value.
_bits
.Length - 3] : 0;
859
long b = (long)value.
_bits
.Length * 32 - c;
879
bool trivialLeft = left.
_bits
== null;
880
bool trivialRight = right.
_bits
== null;
889
Debug.Assert(right.
_bits
!= null);
891
? BigIntegerCalculator.Gcd(right.
_bits
, NumericsHelpers.Abs(left._sign))
892
: new BigInteger(right.
_bits
, negative: false);
897
Debug.Assert(left.
_bits
!= null);
899
? BigIntegerCalculator.Gcd(left.
_bits
, NumericsHelpers.Abs(right._sign))
900
: new BigInteger(left.
_bits
, negative: false);
903
Debug.Assert(left.
_bits
!= null && right.
_bits
!= null);
905
if (BigIntegerCalculator.Compare(left.
_bits
, right.
_bits
) < 0)
907
return GreatestCommonDivisor(right.
_bits
, left.
_bits
);
911
return GreatestCommonDivisor(left.
_bits
, right.
_bits
);
979
bool trivialValue = value.
_bits
== null;
980
bool trivialExponent = exponent.
_bits
== null;
981
bool trivialModulus = modulus.
_bits
== null;
988
trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent.
_bits
!, NumericsHelpers.Abs(modulus._sign)) :
989
trivialExponent ? BigIntegerCalculator.Pow(value.
_bits
!, NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) :
990
BigIntegerCalculator.Pow(value.
_bits
!, exponent.
_bits
!, NumericsHelpers.Abs(modulus._sign));
996
int size = (modulus.
_bits
?.Length ?? 1) << 1;
1006
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), modulus.
_bits
!, bits);
1010
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent.
_bits
!, modulus.
_bits
!, bits);
1015
BigIntegerCalculator.Pow(value.
_bits
!, NumericsHelpers.Abs(exponent._sign), modulus.
_bits
!, bits);
1019
BigIntegerCalculator.Pow(value.
_bits
!, exponent.
_bits
!, modulus.
_bits
!, bits);
1042
bool trivialValue = value.
_bits
== null;
1068
int size = BigIntegerCalculator.PowBound(power, value.
_bits
!.Length);
1074
BigIntegerCalculator.Pow(value.
_bits
, power, bits);
1088
if (
_bits
is null)
1092
hash.AddBytes(MemoryMarshal.AsBytes(
_bits
.AsSpan()));
1108
if (
_bits
== null)
1112
if ((_sign ^ other) < 0 || (cu =
_bits
.Length) > 2)
1117
return
_bits
[0] == uu;
1119
return NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) == uu;
1129
if (
_bits
== null)
1132
int cu =
_bits
.Length;
1136
return
_bits
[0] == other;
1137
return NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) == other;
1145
return _sign == other._sign &&
_bits
.AsSpan().SequenceEqual(other.
_bits
);
1152
if (
_bits
== null)
1155
if ((_sign ^ other) < 0 || (cu =
_bits
.Length) > 2)
1158
ulong uuTmp = cu == 2 ? NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) :
_bits
[0];
1169
if (
_bits
== null)
1171
int cu =
_bits
.Length;
1174
ulong uuTmp = cu == 2 ? NumericsHelpers.MakeUInt64(
_bits
[1],
_bits
[0]) :
_bits
[0];
1190
if (
_bits
== null)
1192
if (other.
_bits
== null)
1197
if (other.
_bits
== null)
1200
int bitsResult = BigIntegerCalculator.Compare(
_bits
, other.
_bits
);
1360
uint[]? bits =
_bits
;
1517
Debug.Assert(
_bits
is null || _sign == 0 ? buffer.Length == 2 : buffer.Length >=
_bits
.Length + 1);
1521
if (
_bits
is null)
1528
_bits
.CopyTo(buffer);
1529
buffer = buffer.Slice(0,
_bits
.Length + 1);
1593
if ((
_bits
is null) || (
_bits
.Length <= 4))
1603
ulong highBits = ((ulong)
_bits
[^1] << kcbitUint) +
_bits
[^2];
1604
double lowBitsCount32 =
_bits
.Length - 2; // if Length > int.MaxValue/32, counting in bits can cause overflow
1714
if (left.
_bits
== null && right.
_bits
== null)
1718
return Add(left.
_bits
, left._sign, right.
_bits
, -1 * right._sign);
1719
return Subtract(left.
_bits
, left._sign, right.
_bits
, right._sign);
1805
if (value.
_bits
== null)
1808
int length = value.
_bits
.Length;
1815
if (length > 2) hi = (int)value.
_bits
[2];
1816
if (length > 1) mi = (int)value.
_bits
[1];
1817
if (length > 0) lo = (int)value.
_bits
[0];
1828
uint[]? bits = value.
_bits
;
1876
if (value.
_bits
== null)
1880
if (value.
_bits
.Length > 1)
1887
return checked((int)value.
_bits
[0]);
1889
if (value.
_bits
[0] > kuMaskHighBit)
1894
return unchecked(-(int)value.
_bits
[0]);
1900
if (value.
_bits
== null)
1905
int len = value.
_bits
.Length;
1914
uu = NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
1918
uu = value.
_bits
[0];
1937
if (value.
_bits
is null)
1942
int len = value.
_bits
.Length;
1954
NumericsHelpers.MakeUInt64((len > 3) ? value.
_bits
[3] : 0, value.
_bits
[2]),
1955
NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0])
1960
uu = NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
1964
uu = value.
_bits
[0];
2013
if (value.
_bits
== null)
2017
else if (value.
_bits
.Length > 1 || value._sign < 0)
2023
return value.
_bits
[0];
2031
if (value.
_bits
== null)
2036
int len = value.
_bits
.Length;
2044
return NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2046
return value.
_bits
[0];
2057
if (value.
_bits
is null)
2062
int len = value.
_bits
.Length;
2072
NumericsHelpers.MakeUInt64((len > 3) ? value.
_bits
[3] : 0, value.
_bits
[2]),
2073
NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0])
2078
return NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2080
return value.
_bits
[0];
2338
if (left.
_bits
is null && right.
_bits
is null)
2347
int size = (left.
_bits
?.Length ?? 1) + 1;
2354
size = (right.
_bits
?.Length ?? 1) + 1;
2394
if (left.
_bits
is null && right.
_bits
is null)
2403
int size = (left.
_bits
?.Length ?? 1) + 1;
2410
size = (right.
_bits
?.Length ?? 1) + 1;
2445
if (left.
_bits
is null && right.
_bits
is null)
2454
int size = (left.
_bits
?.Length ?? 1) + 1;
2461
size = (right.
_bits
?.Length ?? 1) + 1;
2508
int xl = value.
_bits
?.Length ?? 1;
2569
int xl = value.
_bits
?.Length ?? 1;
2654
return new BigInteger(-value._sign, value.
_bits
);
2678
if (left.
_bits
== null && right.
_bits
== null)
2682
return Subtract(left.
_bits
, left._sign, right.
_bits
, -1 * right._sign);
2683
return Add(left.
_bits
, left._sign, right.
_bits
, right._sign);
2691
if (left.
_bits
== null && right.
_bits
== null)
2694
return Multiply(left.
_bits
, left._sign, right.
_bits
, right._sign);
2779
bool trivialDividend = dividend.
_bits
== null;
2780
bool trivialDivisor = divisor.
_bits
== null;
2798
Debug.Assert(dividend.
_bits
!= null);
2800
int size = dividend.
_bits
.Length;
2808
BigIntegerCalculator.Divide(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign), quotient);
2818
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2820
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2826
int size = dividend.
_bits
.Length - divisor.
_bits
.Length + 1;
2831
BigIntegerCalculator.Divide(dividend.
_bits
, divisor.
_bits
, quotient);
2846
bool trivialDividend = dividend.
_bits
== null;
2847
bool trivialDivisor = divisor.
_bits
== null;
2863
Debug.Assert(dividend.
_bits
!= null);
2864
uint remainder = BigIntegerCalculator.Remainder(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign));
2868
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2870
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2876
int size = dividend.
_bits
.Length;
2881
BigIntegerCalculator.Remainder(dividend.
_bits
, divisor.
_bits
, bits);
3063
uint[]? bits =
_bits
;
3113
Debug.Assert(
_bits
is null ? xd.Length == 1 : xd.Length ==
_bits
.Length);
3115
if (
_bits
is null)
3121
_bits
.CopyTo(xd);
3129
if (
_bits
!= null)
3134
Debug.Assert(
_bits
.Length > 0);
3136
Debug.Assert(
_bits
.Length > 1 ||
_bits
[0] >= kuMaskHighBit);
3138
Debug.Assert(
_bits
[
_bits
.Length - 1] != 0);
3140
Debug.Assert(
_bits
.Length <= MaxLength);
3172
if (value.
_bits
is null)
3180
return (value._sign >= 0) ? uint.LeadingZeroCount(value.
_bits
[^1]) : 0;
3188
if (value.
_bits
is null)
3199
for (int i = 0; i < value.
_bits
.Length; i++)
3201
uint part = value.
_bits
[i];
3217
part = ~value.
_bits
[i] + 1;
3222
while ((part == 0) && (i < value.
_bits
.Length));
3224
while (i < value.
_bits
.Length)
3228
part = ~value.
_bits
[i];
3242
int byteCount = (value.
_bits
is null) ? sizeof(int) : (value.
_bits
.Length * 4);
3259
int xl = value.
_bits
?.Length ?? 1;
3377
int byteCount = (value.
_bits
is null) ? sizeof(int) : (value.
_bits
.Length * 4);
3394
int xl = value.
_bits
?.Length ?? 1;
3512
if (value.
_bits
is null)
3522
uint part = value.
_bits
[0];
3524
for (int i = 1; (part == 0) && (i < value.
_bits
.Length); i++)
3526
part = value.
_bits
[i];
3553
uint[]? bits =
_bits
;
3605
uint[]? bits =
_bits
;
3707
uint[]? bits =
_bits
;
3807
uint[]? bits =
_bits
;
3864
if (value.
_bits
is null)
3869
return ((value.
_bits
.Length * 32) - 1) ^ uint.LeadingZeroCount(value.
_bits
[^1]);
3922
if (value.
_bits
is null)
3929
if (sign.
_bits
is null)
3948
if (value.
_bits
is null)
4031
if (value.
_bits
is null)
4035
return (value.
_bits
[0] & 1) == 0;
4071
if (value.
_bits
is null)
4075
return (value.
_bits
[0] & 1) != 0;
4632
if (value.
_bits
is not null)
4649
if (value.
_bits
is not null)
4685
if (value.
_bits
is not null)
4702
if (value.
_bits
is not null)
4746
if (value.
_bits
is not null)
4769
if (value.
_bits
is not null)
4825
if (value.
_bits
is not null)
4827
uint bits = value.
_bits
[0];
4848
if (value.
_bits
is not null)
4850
uint bits = value.
_bits
[0];
4890
if (value.
_bits
is not null)
4892
actualResult = IsNegative(value) ? (short)(~value.
_bits
[0] + 1) : (short)value.
_bits
[0];
4906
if (value.
_bits
is not null)
4908
actualResult = IsNegative(value) ? (int)(~value.
_bits
[0] + 1) : (int)value.
_bits
[0];
4922
if (value.
_bits
is not null)
4926
if (value.
_bits
.Length >= 2)
4928
bits = value.
_bits
[1];
4932
bits |= value.
_bits
[0];
4953
if (value.
_bits
is not null)
4958
if (value.
_bits
.Length >= 4)
4960
upperBits = value.
_bits
[3];
4964
if (value.
_bits
.Length >= 3)
4966
upperBits |= value.
_bits
[2];
4969
if (value.
_bits
.Length >= 2)
4971
lowerBits = value.
_bits
[1];
4975
lowerBits |= value.
_bits
[0];
4998
if (value.
_bits
is not null)
5002
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
5004
bits = value.
_bits
[1];
5008
bits |= value.
_bits
[0];
5035
if (value.
_bits
is not null)
5037
actualResult = IsNegative(value) ? (sbyte)(~value.
_bits
[0] + 1) : (sbyte)value.
_bits
[0];
5057
if (value.
_bits
is not null)
5059
uint bits = value.
_bits
[0];
5080
if (value.
_bits
is not null)
5082
uint bits = value.
_bits
[0];
5103
if (value.
_bits
is not null)
5107
if (value.
_bits
.Length >= 2)
5109
bits = value.
_bits
[1];
5113
bits |= value.
_bits
[0];
5134
if (value.
_bits
is not null)
5139
if (value.
_bits
.Length >= 4)
5141
upperBits = value.
_bits
[3];
5145
if (value.
_bits
.Length >= 3)
5147
upperBits |= value.
_bits
[2];
5150
if (value.
_bits
.Length >= 2)
5152
lowerBits = value.
_bits
[1];
5156
lowerBits |= value.
_bits
[0];
5179
if (value.
_bits
is not null)
5183
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
5185
bits = value.
_bits
[1];
5189
bits |= value.
_bits
[0];