36 writes to _sign
System.Runtime.Numerics (36)
System\Numerics\BigInteger.cs (36)
72
_sign
= value;
84
_sign
= (int)value;
89
_sign
= +1;
100
_sign
= (int)value;
113
_sign
= -1;
118
_sign
= +1;
139
_sign
= (int)value;
144
_sign
= +1;
169
_sign
= 0;
195
_sign
= -_sign;
205
_sign
= -_sign;
246
_sign
= sign;
275
_sign
= bits[0];
276
_sign
*= ((bits[3] & SignMask) != 0) ? -1 : +1;
310
_sign
= ((bits[3] & SignMask) != 0) ? -1 : +1;
315
_sign
= _sign < 0 ? -(int)_bits[0] : (int)_bits[0];
366
_sign
= 0;
374
_sign
= isNegative ? -1 : 0;
380
_sign
= (_sign << 8) | value[i];
387
_sign
= (_sign << 8) | value[i];
396
_sign
= +1;
486
_sign
= -(int)val[0];
495
_sign
= -1;
500
_sign
= -1;
506
_sign
= +1;
525
_sign
= sign;
556
_sign
= negative ? -(int)value[0] : (int)value[0];
566
_sign
= negative ? -1 : +1;
636
_sign
= -(int)magnitude;
642
_sign
= -1;
649
_sign
= -1;
656
_sign
= +1;
661
_sign
= (int)value[0];
675
_sign
= -1;
679
_sign
= +1;
697
_sign
= info.GetInt32("_sign");
230 references to _sign
System.Runtime.Numerics (230)
System\Number.BigInteger.cs (6)
658
TChar.CastFrom(value.
_sign
>= 0 ? '0' : (format == 'x') ? 'f' : 'F'),
700
int charsInHighByte = 9 - byte.LeadingZeroCount(value.
_sign
>= 0 ? highByte : (byte)~highByte);
746
sb.Append(TChar.CastFrom(value.
_sign
>= 0 ? '0' : '1'), digits - charsForBits);
823
spanSuccess = value.
_sign
.TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(destination), out charsWritten, formatSpan, info);
828
spanSuccess = value.
_sign
.TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(destination), out charsWritten, formatSpan, info);
838
return value.
_sign
.ToString(formatString, info);
System\Numerics\BigInteger.cs (224)
42
/// <see cref="
_sign
"/> and <see cref="_bits"/> is <see langword="null"/>.
43
/// For all other values, <see cref="
_sign
"/> is +1 or -1 and the magnitude is in <see cref="_bits"/>.
50
/// everywhere <see cref="
_sign
"/> is used.
195
_sign = -
_sign
;
205
_sign = -
_sign
;
315
_sign =
_sign
< 0 ? -(int)_bits[0] : (int)_bits[0];
380
_sign = (
_sign
<< 8) | value[i];
387
_sign = (
_sign
<< 8) | value[i];
392
if (
_sign
< 0 && !isNegative)
395
_bits = [(uint)
_sign
];
399
if (
_sign
== int.MinValue)
732
info.AddValue("_sign",
_sign
);
777
return BitOperations.IsPow2(
_sign
);
780
if (
_sign
!= 1)
790
public bool IsZero =>
_sign
== 0;
792
public bool IsOne =>
_sign
== 1 && _bits is null;
794
public bool IsEven => _bits is null ? (
_sign
& 1) == 0 : (_bits[0] & 1) == 0;
796
public int Sign => (
_sign
>> 31) - (-
_sign
>> 31);
884
return new BigInteger((int)NumericsHelpers.Abs(value.
_sign
), value._bits);
920
(int q, int r) = Math.DivRem(dividend.
_sign
, divisor.
_sign
);
942
BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
), quotient, out nuint rest);
944
remainder = dividend.
_sign
< 0 ? -(long)rest : (long)rest;
945
return new BigInteger(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
965
remainder = new(rest, dividend.
_sign
< 0);
966
BigInteger result = new(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
987
if (value.
_sign
< 0 || baseValue == 1.0D)
1004
return Math.Log(value.
_sign
, baseValue);
1054
return BigIntegerCalculator.Gcd(NumericsHelpers.Abs(left.
_sign
), NumericsHelpers.Abs(right.
_sign
));
1060
return left.
_sign
!= 0
1061
? BigIntegerCalculator.Gcd(right._bits, NumericsHelpers.Abs(left.
_sign
))
1068
return right.
_sign
!= 0
1069
? BigIntegerCalculator.Gcd(left._bits, NumericsHelpers.Abs(right.
_sign
))
1138
nuint bitsResult = trivialValue && trivialExponent ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), NumericsHelpers.Abs(exponent.
_sign
), NumericsHelpers.Abs(modulus.
_sign
)) :
1139
trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), exponent._bits!, NumericsHelpers.Abs(modulus.
_sign
)) :
1140
trivialExponent ? BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent.
_sign
), NumericsHelpers.Abs(modulus.
_sign
)) :
1141
BigIntegerCalculator.Pow(value._bits!, exponent._bits!, NumericsHelpers.Abs(modulus.
_sign
));
1143
result = value.
_sign
< 0 && !exponent.IsEven ? -(long)bitsResult : (long)bitsResult;
1153
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), NumericsHelpers.Abs(exponent.
_sign
), modulus._bits!, bits);
1157
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), exponent._bits!, modulus._bits!, bits);
1162
BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent.
_sign
), modulus._bits!, bits);
1169
result = new BigInteger(bits, value.
_sign
< 0 && !exponent.IsEven);
1198
if (value.
_sign
== 1)
1203
if (value.
_sign
== -1)
1208
if (value.
_sign
== 0)
1216
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), power, bits);
1217
result = new BigInteger(bits, value.
_sign
< 0 && (exponent & 1) != 0);
1226
result = new BigInteger(bits, value.
_sign
< 0 && (exponent & 1) != 0);
1237
return
_sign
;
1242
hash.Add(
_sign
);
1255
return
_sign
== other;
1260
if ((
_sign
^ other) < 0 || (cu = _bits.Length) > maxLimbs)
1282
if (
_sign
< 0)
1289
return (ulong)
_sign
== other;
1313
return
_sign
== other.
_sign
&& _bits.AsSpan().SequenceEqual(other._bits);
1320
return ((long)
_sign
).CompareTo(other);
1325
if ((
_sign
^ other) < 0 || (cu = _bits.Length) > maxLimbs)
1327
return
_sign
;
1344
return
_sign
* uuTmp.CompareTo(uu);
1350
if (
_sign
< 0)
1357
return ((ulong)(uint)
_sign
).CompareTo(other);
1385
if ((
_sign
^ other.
_sign
) < 0)
1388
return
_sign
< 0 ? -1 : +1;
1395
other._bits is not null ? -other.
_sign
:
1396
_sign
< other.
_sign
? -1 :
1397
_sign
> other.
_sign
? +1 :
1403
return
_sign
;
1407
return
_sign
< 0 ? -bitsResult : bitsResult;
1537
int sign =
_sign
;
1746
Debug.Assert(_bits is null ||
_sign
== 0 ? buffer.Length == 2 : buffer.Length >= _bits.Length + 1);
1752
buffer[0] = (nuint)
_sign
;
1753
highLimb = (
_sign
< 0) ? nuint.MaxValue : 0;
1759
if (
_sign
== -1)
1872
string signStr =
_sign
< 0 ? NumberFormatInfo.CurrentInfo.NegativeSign : "";
1950
return (long)left.
_sign
- right.
_sign
;
1953
return left.
_sign
< 0 != right.
_sign
< 0
1954
? Add(left._bits, left.
_sign
, right._bits, -right.
_sign
)
1955
: Subtract(left._bits, left.
_sign
, right._bits, right.
_sign
);
2028
return value.
_sign
;
2043
int sign = value.
_sign
;
2164
return value.
_sign
;
2173
if (value.
_sign
> 0)
2191
return value.
_sign
;
2214
long ll = value.
_sign
> 0 ? (long)uu : -(long)uu;
2215
if ((ll > 0 && value.
_sign
> 0) || (ll < 0 && value.
_sign
< 0))
2231
return value.
_sign
;
2262
Int128 ll = (value.
_sign
> 0) ? (Int128)uu : -(Int128)uu;
2264
if (((ll > 0) && (value.
_sign
> 0)) || ((ll < 0) && (value.
_sign
< 0)))
2291
return checked((uint)value.
_sign
);
2295
return value._bits.Length <= 1 && value.
_sign
>= 0
2306
return checked((ulong)value.
_sign
);
2311
if (len > maxLimbs || value.
_sign
< 0)
2334
return checked((UInt128)value.
_sign
);
2340
if ((len > maxLimbs) || (value.
_sign
< 0))
2567
left._bits is null && right._bits is null ? (BigInteger)(left.
_sign
& right.
_sign
) :
2583
? (BigInteger)(left.
_sign
| right.
_sign
)
2589
? (BigInteger)(left.
_sign
^ right.
_sign
)
2605
int zLen = (left.
_sign
< 0 || right.
_sign
< 0)
2638
left._bits, left.
_sign
,
2639
right._bits, right.
_sign
,
2670
return LeftShift(value.
_sign
, digitShift, smallShift);
2704
return new BigInteger(value.
_sign
, z);
2772
return new BigInteger(value.
_sign
>> smallShift, null);
2783
return new BigInteger(value.
_sign
>> 31, null);
2793
bool neg = value.
_sign
< 0;
2817
return ~value.
_sign
; // implicit int -> BigInteger handles int.MinValue
2822
if (value.
_sign
>= 0)
2845
public static BigInteger operator -(BigInteger value) => new BigInteger(-value.
_sign
, value._bits);
2853
return (long)value.
_sign
+ 1;
2858
if (value.
_sign
>= 0)
2883
return (long)value.
_sign
- 1;
2888
if (value.
_sign
>= 0)
2913
return (long)left.
_sign
+ right.
_sign
;
2916
return left.
_sign
< 0 != right.
_sign
< 0
2917
? Subtract(left._bits, left.
_sign
, right._bits, -right.
_sign
)
2918
: Add(left._bits, left.
_sign
, right._bits, right.
_sign
);
2923
? (BigInteger)((long)left.
_sign
* right.
_sign
)
2924
: Multiply(left._bits, left.
_sign
, right._bits, right.
_sign
);
2988
return dividend.
_sign
/ divisor.
_sign
;
3006
BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
), quotient);
3008
BigInteger result = new BigInteger(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
3027
BigInteger result = new(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
3042
return dividend.
_sign
% divisor.
_sign
;
3055
nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
));
3056
return dividend.
_sign
< 0 ? -(long)remainder : (long)remainder;
3070
BigInteger result = new(bits, dividend.
_sign
< 0);
3158
int sign =
_sign
;
3198
Debug.Assert(
_sign
is 1 or -1);
3211
Debug.Assert(
_sign
> int.MinValue);
3239
return uint.Log10((uint)value.
_sign
);
3270
return uint.LeadingZeroCount((uint)value.
_sign
);
3274
if (value.
_sign
< 0)
3290
return int.PopCount(value.
_sign
);
3295
if (value.
_sign
>= 0)
3348
bool neg = value.
_sign
< 0;
3352
uint rs = uint.RotateLeft((uint)value.
_sign
, rotateAmount);
3369
bool neg = value.
_sign
< 0;
3373
uint rs = uint.RotateRight((uint)value.
_sign
, rotateAmount);
3643
return int.TrailingZeroCount(value.
_sign
);
3685
int value =
_sign
;
3692
if (
_sign
>= 0)
3729
BinaryPrimitives.WriteIntPtrBigEndian(destination,
_sign
);
3731
else if (
_sign
>= 0)
3807
BinaryPrimitives.WriteIntPtrLittleEndian(destination,
_sign
);
3809
else if (
_sign
>= 0)
3883
if (
_sign
< 0)
3926
? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value.
_sign
| 1))
3970
nint currentSign = value.
_sign
;
3977
nint targetSign = sign.
_sign
;
3997
? value.
_sign
> 0 ? 1
3998
: (value.
_sign
< 0 ? -1 : 0) : value.
_sign
;
4075
? (value.
_sign
& 1) == 0
4097
return value.
_sign
< 0;
4110
? (value.
_sign
& 1) != 0
4117
return value.
_sign
>= 0;
4132
return value.
_sign
== 0;
4666
actualResult = (value.
_sign
>= byte.MaxValue) ? byte.MaxValue :
4667
(value.
_sign
<= byte.MinValue) ? byte.MinValue : (byte)value.
_sign
;
4683
actualResult = (value.
_sign
>= char.MaxValue) ? char.MaxValue :
4684
(value.
_sign
<= char.MinValue) ? char.MinValue : (char)value.
_sign
;
4725
actualResult = (value.
_sign
>= short.MaxValue) ? short.MaxValue :
4726
(value.
_sign
<= short.MinValue) ? short.MinValue : (short)value.
_sign
;
4742
actualResult = (value.
_sign
>= int.MaxValue) ? int.MaxValue :
4743
(value.
_sign
<= int.MinValue) ? int.MinValue : value.
_sign
;
4786
actualResult = (value.
_sign
>= sbyte.MaxValue) ? sbyte.MaxValue :
4787
(value.
_sign
<= sbyte.MinValue) ? sbyte.MinValue : (sbyte)value.
_sign
;
4809
actualResult = (value.
_sign
>= ushort.MaxValue) ? ushort.MaxValue :
4810
(value.
_sign
<= ushort.MinValue) ? ushort.MinValue : (ushort)value.
_sign
;
4872
actualResult = (byte)value.
_sign
;
4895
actualResult = (char)value.
_sign
;
4936
actualResult = (short)value.
_sign
;
4952
actualResult = value.
_sign
;
4992
actualResult = value.
_sign
;
5049
actualResult = (Int128)(long)value.
_sign
;
5072
actualResult = value.
_sign
;
5094
actualResult = (sbyte)value.
_sign
;
5123
actualResult = (ushort)value.
_sign
;
5146
actualResult = (uint)value.
_sign
;
5186
actualResult = (ulong)value.
_sign
;
5243
actualResult = (UInt128)(Int128)(long)value.
_sign
;
5266
actualResult = (nuint)value.
_sign
;
5319
return new BigInteger((nint)value.
_sign
>>> smallShift);
5333
bool neg = value.
_sign
< 0;
5420
return new BigInteger(value.
_sign
>> 31, null);