36 writes to _sign
System.Runtime.Numerics (36)
System\Numerics\BigInteger.cs (36)
76
_sign
= value;
88
_sign
= (int)value;
93
_sign
= +1;
104
_sign
= (int)value;
117
_sign
= -1;
122
_sign
= +1;
143
_sign
= (int)value;
148
_sign
= +1;
173
_sign
= 0;
199
_sign
= -_sign;
209
_sign
= -_sign;
250
_sign
= sign;
279
_sign
= bits[0];
280
_sign
*= ((bits[3] & SignMask) != 0) ? -1 : +1;
314
_sign
= ((bits[3] & SignMask) != 0) ? -1 : +1;
319
_sign
= _sign < 0 ? -(int)_bits[0] : (int)_bits[0];
370
_sign
= 0;
378
_sign
= isNegative ? -1 : 0;
384
_sign
= (_sign << 8) | value[i];
391
_sign
= (_sign << 8) | value[i];
400
_sign
= +1;
490
_sign
= -(int)val[0];
499
_sign
= -1;
504
_sign
= -1;
510
_sign
= +1;
529
_sign
= sign;
560
_sign
= negative ? -(int)value[0] : (int)value[0];
570
_sign
= negative ? -1 : +1;
640
_sign
= -(int)magnitude;
646
_sign
= -1;
653
_sign
= -1;
660
_sign
= +1;
665
_sign
= (int)value[0];
679
_sign
= -1;
683
_sign
= +1;
701
_sign
= info.GetInt32("_sign");
245 references to _sign
System.Runtime.Numerics (245)
System\Number.BigInteger.cs (5)
679
TChar.CastFrom(value.
_sign
>= 0 ? '0' : (format == 'x') ? 'f' : 'F'),
721
int charsInHighByte = 9 - byte.LeadingZeroCount(value.
_sign
>= 0 ? highByte : (byte)~highByte);
767
sb.Append(TChar.CastFrom(value.
_sign
>= 0 ? '0' : '1'), digits - charsForBits);
842
spanSuccess = TryFormatInt32(value.
_sign
, destination, formatSpan, info, out charsWritten);
850
return value.
_sign
.ToString(formatString, info);
System\Numerics\BigInteger.cs (240)
46
/// <see cref="
_sign
"/> and <see cref="_bits"/> is <see langword="null"/>.
47
/// For all other values, <see cref="
_sign
"/> is +1 or -1 and the magnitude is in <see cref="_bits"/>.
54
/// everywhere <see cref="
_sign
"/> is used.
199
_sign = -
_sign
;
209
_sign = -
_sign
;
319
_sign =
_sign
< 0 ? -(int)_bits[0] : (int)_bits[0];
384
_sign = (
_sign
<< 8) | value[i];
391
_sign = (
_sign
<< 8) | value[i];
396
if (
_sign
< 0 && !isNegative)
399
_bits = [(uint)
_sign
];
403
if (
_sign
== int.MinValue)
736
info.AddValue("_sign",
_sign
);
781
return BitOperations.IsPow2(
_sign
);
784
if (
_sign
!= 1)
794
public bool IsZero =>
_sign
== 0;
796
public bool IsOne =>
_sign
== 1 && _bits is null;
798
public bool IsEven => _bits is null ? (
_sign
& 1) == 0 : (_bits[0] & 1) == 0;
800
public int Sign => (
_sign
>> 31) - (-
_sign
>> 31);
888
return new BigInteger((int)NumericsHelpers.Abs(value.
_sign
), value._bits);
924
(int q, int r) = Math.DivRem(dividend.
_sign
, divisor.
_sign
);
946
BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
), quotient, out nuint rest);
948
remainder = dividend.
_sign
< 0 ? -(long)rest : (long)rest;
949
return new BigInteger(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
990
remainder = new(rest, dividend.
_sign
< 0);
991
BigInteger result = new(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
1012
if (value.
_sign
< 0 || baseValue == 1.0D)
1029
return Math.Log(value.
_sign
, baseValue);
1099
return BigIntegerCalculator.Gcd(NumericsHelpers.Abs(left.
_sign
), NumericsHelpers.Abs(right.
_sign
));
1105
return left.
_sign
!= 0
1106
? BigIntegerCalculator.Gcd(right._bits, NumericsHelpers.Abs(left.
_sign
))
1113
return right.
_sign
!= 0
1114
? BigIntegerCalculator.Gcd(left._bits, NumericsHelpers.Abs(right.
_sign
))
1194
nuint magnitude = NumericsHelpers.Abs(value.
_sign
);
1245
bool negative = (dividend.
_sign
< 0) != (divisor.
_sign
< 0);
1246
BigInteger magnitude = dividend.
_sign
< 0 ? -dividend : dividend;
1272
return new BigInteger(dividendBits[..limbCount], dividend.
_sign
< 0);
1278
BigInteger remainder = new(bits, dividend.
_sign
< 0);
1321
return value.
_sign
< 0 && !exponent.IsEven ? s_minusOne : s_one;
1331
return CreatePowerOfTwo(resultExponent, value.
_sign
< 0 && !exponent.IsEven);
1342
nuint bitsResult = trivialValue && trivialExponent ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), NumericsHelpers.Abs(exponent.
_sign
), NumericsHelpers.Abs(modulus.
_sign
)) :
1343
trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), exponent._bits!, NumericsHelpers.Abs(modulus.
_sign
)) :
1344
trivialExponent ? BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent.
_sign
), NumericsHelpers.Abs(modulus.
_sign
)) :
1345
BigIntegerCalculator.Pow(value._bits!, exponent._bits!, NumericsHelpers.Abs(modulus.
_sign
));
1347
result = value.
_sign
< 0 && !exponent.IsEven ? -(long)bitsResult : (long)bitsResult;
1357
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), NumericsHelpers.Abs(exponent.
_sign
), modulus._bits!, bits);
1361
BigIntegerCalculator.Pow(NumericsHelpers.Abs(value.
_sign
), exponent._bits!, modulus._bits!, bits);
1366
BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent.
_sign
), modulus._bits!, bits);
1373
result = new BigInteger(bits, value.
_sign
< 0 && !exponent.IsEven);
1398
return CreatePowerOfTwo(resultExponent, value.
_sign
< 0 && (exponent & 1) != 0);
1413
if (value.
_sign
== 1)
1418
if (value.
_sign
== -1)
1423
nuint magnitude = NumericsHelpers.Abs(value.
_sign
);
1445
result = new BigInteger(genericBits, value.
_sign
< 0 && (exponent & 1) != 0);
1530
return value.
_sign
< 0 && (exponent & 1) != 0 ? -exactPower : exactPower;
1660
result = new BigInteger(bits, value.
_sign
< 0 && (exponent & 1) != 0);
1669
result = new BigInteger(bits, value.
_sign
< 0 && (exponent & 1) != 0);
1680
return
_sign
;
1685
hash.Add(
_sign
);
1698
return
_sign
== other;
1703
if ((
_sign
^ other) < 0 || (cu = _bits.Length) > maxLimbs)
1725
if (
_sign
< 0)
1732
return (ulong)
_sign
== other;
1756
return
_sign
== other.
_sign
&& _bits.AsSpan().SequenceEqual(other._bits);
1763
return ((long)
_sign
).CompareTo(other);
1768
if ((
_sign
^ other) < 0 || (cu = _bits.Length) > maxLimbs)
1770
return
_sign
;
1787
return
_sign
* uuTmp.CompareTo(uu);
1793
if (
_sign
< 0)
1800
return ((ulong)(uint)
_sign
).CompareTo(other);
1828
if ((
_sign
^ other.
_sign
) < 0)
1831
return
_sign
< 0 ? -1 : +1;
1838
other._bits is not null ? -other.
_sign
:
1839
_sign
< other.
_sign
? -1 :
1840
_sign
> other.
_sign
? +1 :
1846
return
_sign
;
1850
return
_sign
< 0 ? -bitsResult : bitsResult;
1980
int sign =
_sign
;
2189
Debug.Assert(_bits is null ||
_sign
== 0 ? buffer.Length == 2 : buffer.Length >= _bits.Length + 1);
2195
buffer[0] = (nuint)
_sign
;
2196
highLimb = (
_sign
< 0) ? nuint.MaxValue : 0;
2202
if (
_sign
== -1)
2315
string signStr =
_sign
< 0 ? NumberFormatInfo.CurrentInfo.NegativeSign : "";
2402
return (long)left.
_sign
- right.
_sign
;
2405
return left.
_sign
< 0 != right.
_sign
< 0
2406
? Add(left._bits, left.
_sign
, right._bits, -right.
_sign
)
2407
: Subtract(left._bits, left.
_sign
, right._bits, right.
_sign
);
2550
return value.
_sign
;
2558
int sign = value.
_sign
;
2591
int sign = value.
_sign
;
2725
int sign = value.
_sign
;
2744
int sign = value.
_sign
;
2770
return value.
_sign
;
2779
if (value.
_sign
> 0)
2797
return value.
_sign
;
2820
long ll = value.
_sign
> 0 ? (long)uu : -(long)uu;
2821
if ((ll > 0 && value.
_sign
> 0) || (ll < 0 && value.
_sign
< 0))
2837
return value.
_sign
;
2868
Int128 ll = (value.
_sign
> 0) ? (Int128)uu : -(Int128)uu;
2870
if (((ll > 0) && (value.
_sign
> 0)) || ((ll < 0) && (value.
_sign
< 0)))
2889
int sign = value.
_sign
;
2922
return checked((uint)value.
_sign
);
2926
return value._bits.Length <= 1 && value.
_sign
>= 0
2937
return checked((ulong)value.
_sign
);
2942
if (len > maxLimbs || value.
_sign
< 0)
2965
return checked((UInt128)value.
_sign
);
2971
if ((len > maxLimbs) || (value.
_sign
< 0))
3198
left._bits is null && right._bits is null ? (BigInteger)(left.
_sign
& right.
_sign
) :
3214
? (BigInteger)(left.
_sign
| right.
_sign
)
3220
? (BigInteger)(left.
_sign
^ right.
_sign
)
3236
int zLen = (left.
_sign
< 0 || right.
_sign
< 0)
3269
left._bits, left.
_sign
,
3270
right._bits, right.
_sign
,
3301
return LeftShift(value.
_sign
, digitShift, smallShift);
3345
return new BigInteger(value.
_sign
, z);
3423
return new BigInteger(value.
_sign
>> smallShift, null);
3434
return new BigInteger(value.
_sign
>> 31, null);
3444
bool neg = value.
_sign
< 0;
3468
return ~value.
_sign
; // implicit int -> BigInteger handles int.MinValue
3473
if (value.
_sign
>= 0)
3496
public static BigInteger operator -(BigInteger value) => new BigInteger(-value.
_sign
, value._bits);
3504
return (long)value.
_sign
+ 1;
3509
if (value.
_sign
>= 0)
3534
return (long)value.
_sign
- 1;
3539
if (value.
_sign
>= 0)
3564
return (long)left.
_sign
+ right.
_sign
;
3567
return left.
_sign
< 0 != right.
_sign
< 0
3568
? Subtract(left._bits, left.
_sign
, right._bits, -right.
_sign
)
3569
: Add(left._bits, left.
_sign
, right._bits, right.
_sign
);
3576
return (BigInteger)((long)left.
_sign
* right.
_sign
);
3582
return left.
_sign
< 0 ? -result : result;
3588
return right.
_sign
< 0 ? -result : result;
3591
return Multiply(left._bits, left.
_sign
, right._bits, right.
_sign
);
3656
return dividend.
_sign
/ divisor.
_sign
;
3674
BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
), quotient);
3676
BigInteger result = new BigInteger(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
3713
BigInteger result = new(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
3728
return dividend.
_sign
% divisor.
_sign
;
3741
nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
));
3742
return dividend.
_sign
< 0 ? -(long)remainder : (long)remainder;
3775
BigInteger result = new(bits, dividend.
_sign
< 0);
3866
int sign =
_sign
;
3906
Debug.Assert(
_sign
is 1 or -1);
3919
Debug.Assert(
_sign
> int.MinValue);
3947
return uint.Log10((uint)value.
_sign
);
3978
return uint.LeadingZeroCount((uint)value.
_sign
);
3982
if (value.
_sign
< 0)
3998
return int.PopCount(value.
_sign
);
4003
if (value.
_sign
>= 0)
4056
bool neg = value.
_sign
< 0;
4060
uint rs = uint.RotateLeft((uint)value.
_sign
, rotateAmount);
4077
bool neg = value.
_sign
< 0;
4081
uint rs = uint.RotateRight((uint)value.
_sign
, rotateAmount);
4356
return int.TrailingZeroCount(value.
_sign
);
4396
int value =
_sign
;
4403
if (
_sign
>= 0)
4440
BinaryPrimitives.WriteIntPtrBigEndian(destination,
_sign
);
4442
else if (
_sign
>= 0)
4518
BinaryPrimitives.WriteIntPtrLittleEndian(destination,
_sign
);
4520
else if (
_sign
>= 0)
4594
if (
_sign
< 0)
4637
? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value.
_sign
| 1))
4681
nint currentSign = value.
_sign
;
4688
nint targetSign = sign.
_sign
;
4708
? value.
_sign
> 0 ? 1
4709
: (value.
_sign
< 0 ? -1 : 0) : value.
_sign
;
4786
? (value.
_sign
& 1) == 0
4808
return value.
_sign
< 0;
4821
? (value.
_sign
& 1) != 0
4828
return value.
_sign
>= 0;
4843
return value.
_sign
== 0;
5377
actualResult = (value.
_sign
>= byte.MaxValue) ? byte.MaxValue :
5378
(value.
_sign
<= byte.MinValue) ? byte.MinValue : (byte)value.
_sign
;
5394
actualResult = (value.
_sign
>= char.MaxValue) ? char.MaxValue :
5395
(value.
_sign
<= char.MinValue) ? char.MinValue : (char)value.
_sign
;
5436
actualResult = (value.
_sign
>= short.MaxValue) ? short.MaxValue :
5437
(value.
_sign
<= short.MinValue) ? short.MinValue : (short)value.
_sign
;
5453
actualResult = (value.
_sign
>= int.MaxValue) ? int.MaxValue :
5454
(value.
_sign
<= int.MinValue) ? int.MinValue : value.
_sign
;
5497
actualResult = (value.
_sign
>= sbyte.MaxValue) ? sbyte.MaxValue :
5498
(value.
_sign
<= sbyte.MinValue) ? sbyte.MinValue : (sbyte)value.
_sign
;
5520
actualResult = (value.
_sign
>= ushort.MaxValue) ? ushort.MaxValue :
5521
(value.
_sign
<= ushort.MinValue) ? ushort.MinValue : (ushort)value.
_sign
;
5583
actualResult = (byte)value.
_sign
;
5606
actualResult = (char)value.
_sign
;
5647
actualResult = (short)value.
_sign
;
5663
actualResult = value.
_sign
;
5703
actualResult = value.
_sign
;
5760
actualResult = (Int128)(long)value.
_sign
;
5783
actualResult = value.
_sign
;
5805
actualResult = (sbyte)value.
_sign
;
5834
actualResult = (ushort)value.
_sign
;
5857
actualResult = (uint)value.
_sign
;
5897
actualResult = (ulong)value.
_sign
;
5954
actualResult = (UInt128)(Int128)(long)value.
_sign
;
5977
actualResult = (nuint)value.
_sign
;
6030
return new BigInteger((nint)value.
_sign
>>> smallShift);
6044
bool neg = value.
_sign
< 0;
6131
return new BigInteger(value.
_sign
>> 31, null);