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();
316 references to _bits
System.Runtime.Numerics (316)
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 (313)
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
;
1544
Debug.Assert(
_bits
is null || _sign == 0 ? buffer.Length == 2 : buffer.Length >=
_bits
.Length + 1);
1548
if (
_bits
is null)
1555
_bits
.CopyTo(buffer);
1556
buffer = buffer.Slice(0,
_bits
.Length + 1);
1620
if ((
_bits
is null) || (
_bits
.Length <= 4))
1630
ulong highBits = ((ulong)
_bits
[^1] << kcbitUint) +
_bits
[^2];
1631
double lowBitsCount32 =
_bits
.Length - 2; // if Length > int.MaxValue/32, counting in bits can cause overflow
1741
if (left.
_bits
== null && right.
_bits
== null)
1745
return Add(left.
_bits
, left._sign, right.
_bits
, -1 * right._sign);
1746
return Subtract(left.
_bits
, left._sign, right.
_bits
, right._sign);
1832
if (value.
_bits
== null)
1835
int length = value.
_bits
.Length;
1842
if (length > 2) hi = (int)value.
_bits
[2];
1843
if (length > 1) mi = (int)value.
_bits
[1];
1844
if (length > 0) lo = (int)value.
_bits
[0];
1855
uint[]? bits = value.
_bits
;
1903
if (value.
_bits
== null)
1907
if (value.
_bits
.Length > 1)
1914
return checked((int)value.
_bits
[0]);
1916
if (value.
_bits
[0] > kuMaskHighBit)
1921
return unchecked(-(int)value.
_bits
[0]);
1927
if (value.
_bits
== null)
1932
int len = value.
_bits
.Length;
1941
uu = NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
1945
uu = value.
_bits
[0];
1964
if (value.
_bits
is null)
1969
int len = value.
_bits
.Length;
1981
NumericsHelpers.MakeUInt64((len > 3) ? value.
_bits
[3] : 0, value.
_bits
[2]),
1982
NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0])
1987
uu = NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
1991
uu = value.
_bits
[0];
2040
if (value.
_bits
== null)
2044
else if (value.
_bits
.Length > 1 || value._sign < 0)
2050
return value.
_bits
[0];
2058
if (value.
_bits
== null)
2063
int len = value.
_bits
.Length;
2071
return NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2073
return value.
_bits
[0];
2084
if (value.
_bits
is null)
2089
int len = value.
_bits
.Length;
2099
NumericsHelpers.MakeUInt64((len > 3) ? value.
_bits
[3] : 0, value.
_bits
[2]),
2100
NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0])
2105
return NumericsHelpers.MakeUInt64(value.
_bits
[1], value.
_bits
[0]);
2107
return value.
_bits
[0];
2365
if (left.
_bits
is null && right.
_bits
is null)
2374
int size = (left.
_bits
?.Length ?? 1) + 1;
2381
size = (right.
_bits
?.Length ?? 1) + 1;
2421
if (left.
_bits
is null && right.
_bits
is null)
2430
int size = (left.
_bits
?.Length ?? 1) + 1;
2437
size = (right.
_bits
?.Length ?? 1) + 1;
2472
if (left.
_bits
is null && right.
_bits
is null)
2481
int size = (left.
_bits
?.Length ?? 1) + 1;
2488
size = (right.
_bits
?.Length ?? 1) + 1;
2535
int xl = value.
_bits
?.Length ?? 1;
2596
int xl = value.
_bits
?.Length ?? 1;
2681
return new BigInteger(-value._sign, value.
_bits
);
2705
if (left.
_bits
== null && right.
_bits
== null)
2709
return Subtract(left.
_bits
, left._sign, right.
_bits
, -1 * right._sign);
2710
return Add(left.
_bits
, left._sign, right.
_bits
, right._sign);
2718
if (left.
_bits
== null && right.
_bits
== null)
2721
return Multiply(left.
_bits
, left._sign, right.
_bits
, right._sign);
2806
bool trivialDividend = dividend.
_bits
== null;
2807
bool trivialDivisor = divisor.
_bits
== null;
2825
Debug.Assert(dividend.
_bits
!= null);
2827
int size = dividend.
_bits
.Length;
2835
BigIntegerCalculator.Divide(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign), quotient);
2845
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2847
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2853
int size = dividend.
_bits
.Length - divisor.
_bits
.Length + 1;
2858
BigIntegerCalculator.Divide(dividend.
_bits
, divisor.
_bits
, quotient);
2873
bool trivialDividend = dividend.
_bits
== null;
2874
bool trivialDivisor = divisor.
_bits
== null;
2890
Debug.Assert(dividend.
_bits
!= null);
2891
uint remainder = BigIntegerCalculator.Remainder(dividend.
_bits
, NumericsHelpers.Abs(divisor._sign));
2895
Debug.Assert(dividend.
_bits
!= null && divisor.
_bits
!= null);
2897
if (dividend.
_bits
.Length < divisor.
_bits
.Length)
2903
int size = dividend.
_bits
.Length;
2908
BigIntegerCalculator.Remainder(dividend.
_bits
, divisor.
_bits
, bits);
3090
uint[]? bits =
_bits
;
3140
Debug.Assert(
_bits
is null ? xd.Length == 1 : xd.Length ==
_bits
.Length);
3142
if (
_bits
is null)
3148
_bits
.CopyTo(xd);
3156
if (
_bits
!= null)
3161
Debug.Assert(
_bits
.Length > 0);
3163
Debug.Assert(
_bits
.Length > 1 ||
_bits
[0] >= kuMaskHighBit);
3165
Debug.Assert(
_bits
[
_bits
.Length - 1] != 0);
3167
Debug.Assert(
_bits
.Length <= MaxLength);
3199
if (value.
_bits
is null)
3207
return (value._sign >= 0) ? uint.LeadingZeroCount(value.
_bits
[^1]) : 0;
3215
if (value.
_bits
is null)
3226
for (int i = 0; i < value.
_bits
.Length; i++)
3228
uint part = value.
_bits
[i];
3244
part = ~value.
_bits
[i] + 1;
3249
while ((part == 0) && (i < value.
_bits
.Length));
3251
while (i < value.
_bits
.Length)
3255
part = ~value.
_bits
[i];
3272
scoped ReadOnlySpan<uint> bits = value.
_bits
;
3427
scoped ReadOnlySpan<uint> bits = value.
_bits
;
3571
if (value.
_bits
is null)
3581
uint part = value.
_bits
[0];
3583
for (int i = 1; (part == 0) && (i < value.
_bits
.Length); i++)
3585
part = value.
_bits
[i];
3612
uint[]? bits =
_bits
;
3664
uint[]? bits =
_bits
;
3766
uint[]? bits =
_bits
;
3866
uint[]? bits =
_bits
;
3923
if (value.
_bits
is null)
3928
return ((value.
_bits
.Length * 32) - 1) ^ uint.LeadingZeroCount(value.
_bits
[^1]);
3981
if (value.
_bits
is null)
3988
if (sign.
_bits
is null)
4007
if (value.
_bits
is null)
4090
if (value.
_bits
is null)
4094
return (value.
_bits
[0] & 1) == 0;
4130
if (value.
_bits
is null)
4134
return (value.
_bits
[0] & 1) != 0;
4691
if (value.
_bits
is not null)
4708
if (value.
_bits
is not null)
4744
if (value.
_bits
is not null)
4761
if (value.
_bits
is not null)
4805
if (value.
_bits
is not null)
4828
if (value.
_bits
is not null)
4884
if (value.
_bits
is not null)
4886
uint bits = value.
_bits
[0];
4907
if (value.
_bits
is not null)
4909
uint bits = value.
_bits
[0];
4949
if (value.
_bits
is not null)
4951
actualResult = IsNegative(value) ? (short)(~value.
_bits
[0] + 1) : (short)value.
_bits
[0];
4965
if (value.
_bits
is not null)
4967
actualResult = IsNegative(value) ? (int)(~value.
_bits
[0] + 1) : (int)value.
_bits
[0];
4981
if (value.
_bits
is not null)
4985
if (value.
_bits
.Length >= 2)
4987
bits = value.
_bits
[1];
4991
bits |= value.
_bits
[0];
5012
if (value.
_bits
is not null)
5017
if (value.
_bits
.Length >= 4)
5019
upperBits = value.
_bits
[3];
5023
if (value.
_bits
.Length >= 3)
5025
upperBits |= value.
_bits
[2];
5028
if (value.
_bits
.Length >= 2)
5030
lowerBits = value.
_bits
[1];
5034
lowerBits |= value.
_bits
[0];
5057
if (value.
_bits
is not null)
5061
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
5063
bits = value.
_bits
[1];
5067
bits |= value.
_bits
[0];
5094
if (value.
_bits
is not null)
5096
actualResult = IsNegative(value) ? (sbyte)(~value.
_bits
[0] + 1) : (sbyte)value.
_bits
[0];
5116
if (value.
_bits
is not null)
5118
uint bits = value.
_bits
[0];
5139
if (value.
_bits
is not null)
5141
uint bits = value.
_bits
[0];
5162
if (value.
_bits
is not null)
5166
if (value.
_bits
.Length >= 2)
5168
bits = value.
_bits
[1];
5172
bits |= value.
_bits
[0];
5193
if (value.
_bits
is not null)
5198
if (value.
_bits
.Length >= 4)
5200
upperBits = value.
_bits
[3];
5204
if (value.
_bits
.Length >= 3)
5206
upperBits |= value.
_bits
[2];
5209
if (value.
_bits
.Length >= 2)
5211
lowerBits = value.
_bits
[1];
5215
lowerBits |= value.
_bits
[0];
5238
if (value.
_bits
is not null)
5242
if (Environment.Is64BitProcess && (value.
_bits
.Length >= 2))
5244
bits = value.
_bits
[1];
5248
bits |= value.
_bits
[0];
5303
scoped ReadOnlySpan<uint> bits = value.
_bits
;