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");
234 references to _sign
System.Runtime.Numerics (234)
System\Number.BigInteger.cs (6)
678
TChar.CastFrom(value.
_sign
>= 0 ? '0' : (format == 'x') ? 'f' : 'F'),
720
int charsInHighByte = 9 - byte.LeadingZeroCount(value.
_sign
>= 0 ? highByte : (byte)~highByte);
766
sb.Append(TChar.CastFrom(value.
_sign
>= 0 ? '0' : '1'), digits - charsForBits);
843
spanSuccess = value.
_sign
.TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(destination), out charsWritten, formatSpan, info);
848
spanSuccess = value.
_sign
.TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(destination), out charsWritten, formatSpan, info);
858
return value.
_sign
.ToString(formatString, info);
System\Numerics\BigInteger.cs (228)
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
;
2036
int sign = value.
_sign
;
2069
int sign = value.
_sign
;
2203
int sign = value.
_sign
;
2222
int sign = value.
_sign
;
2248
return value.
_sign
;
2257
if (value.
_sign
> 0)
2275
return value.
_sign
;
2298
long ll = value.
_sign
> 0 ? (long)uu : -(long)uu;
2299
if ((ll > 0 && value.
_sign
> 0) || (ll < 0 && value.
_sign
< 0))
2315
return value.
_sign
;
2346
Int128 ll = (value.
_sign
> 0) ? (Int128)uu : -(Int128)uu;
2348
if (((ll > 0) && (value.
_sign
> 0)) || ((ll < 0) && (value.
_sign
< 0)))
2367
int sign = value.
_sign
;
2400
return checked((uint)value.
_sign
);
2404
return value._bits.Length <= 1 && value.
_sign
>= 0
2415
return checked((ulong)value.
_sign
);
2420
if (len > maxLimbs || value.
_sign
< 0)
2443
return checked((UInt128)value.
_sign
);
2449
if ((len > maxLimbs) || (value.
_sign
< 0))
2676
left._bits is null && right._bits is null ? (BigInteger)(left.
_sign
& right.
_sign
) :
2692
? (BigInteger)(left.
_sign
| right.
_sign
)
2698
? (BigInteger)(left.
_sign
^ right.
_sign
)
2714
int zLen = (left.
_sign
< 0 || right.
_sign
< 0)
2747
left._bits, left.
_sign
,
2748
right._bits, right.
_sign
,
2779
return LeftShift(value.
_sign
, digitShift, smallShift);
2813
return new BigInteger(value.
_sign
, z);
2881
return new BigInteger(value.
_sign
>> smallShift, null);
2892
return new BigInteger(value.
_sign
>> 31, null);
2902
bool neg = value.
_sign
< 0;
2926
return ~value.
_sign
; // implicit int -> BigInteger handles int.MinValue
2931
if (value.
_sign
>= 0)
2954
public static BigInteger operator -(BigInteger value) => new BigInteger(-value.
_sign
, value._bits);
2962
return (long)value.
_sign
+ 1;
2967
if (value.
_sign
>= 0)
2992
return (long)value.
_sign
- 1;
2997
if (value.
_sign
>= 0)
3022
return (long)left.
_sign
+ right.
_sign
;
3025
return left.
_sign
< 0 != right.
_sign
< 0
3026
? Subtract(left._bits, left.
_sign
, right._bits, -right.
_sign
)
3027
: Add(left._bits, left.
_sign
, right._bits, right.
_sign
);
3032
? (BigInteger)((long)left.
_sign
* right.
_sign
)
3033
: Multiply(left._bits, left.
_sign
, right._bits, right.
_sign
);
3097
return dividend.
_sign
/ divisor.
_sign
;
3115
BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
), quotient);
3117
BigInteger result = new BigInteger(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
3136
BigInteger result = new(quotient, (dividend.
_sign
< 0) ^ (divisor.
_sign
< 0));
3151
return dividend.
_sign
% divisor.
_sign
;
3164
nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor.
_sign
));
3165
return dividend.
_sign
< 0 ? -(long)remainder : (long)remainder;
3179
BigInteger result = new(bits, dividend.
_sign
< 0);
3267
int sign =
_sign
;
3307
Debug.Assert(
_sign
is 1 or -1);
3320
Debug.Assert(
_sign
> int.MinValue);
3348
return uint.Log10((uint)value.
_sign
);
3379
return uint.LeadingZeroCount((uint)value.
_sign
);
3383
if (value.
_sign
< 0)
3399
return int.PopCount(value.
_sign
);
3404
if (value.
_sign
>= 0)
3457
bool neg = value.
_sign
< 0;
3461
uint rs = uint.RotateLeft((uint)value.
_sign
, rotateAmount);
3478
bool neg = value.
_sign
< 0;
3482
uint rs = uint.RotateRight((uint)value.
_sign
, rotateAmount);
3752
return int.TrailingZeroCount(value.
_sign
);
3794
int value =
_sign
;
3801
if (
_sign
>= 0)
3838
BinaryPrimitives.WriteIntPtrBigEndian(destination,
_sign
);
3840
else if (
_sign
>= 0)
3916
BinaryPrimitives.WriteIntPtrLittleEndian(destination,
_sign
);
3918
else if (
_sign
>= 0)
3992
if (
_sign
< 0)
4035
? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value.
_sign
| 1))
4079
nint currentSign = value.
_sign
;
4086
nint targetSign = sign.
_sign
;
4106
? value.
_sign
> 0 ? 1
4107
: (value.
_sign
< 0 ? -1 : 0) : value.
_sign
;
4184
? (value.
_sign
& 1) == 0
4206
return value.
_sign
< 0;
4219
? (value.
_sign
& 1) != 0
4226
return value.
_sign
>= 0;
4241
return value.
_sign
== 0;
4775
actualResult = (value.
_sign
>= byte.MaxValue) ? byte.MaxValue :
4776
(value.
_sign
<= byte.MinValue) ? byte.MinValue : (byte)value.
_sign
;
4792
actualResult = (value.
_sign
>= char.MaxValue) ? char.MaxValue :
4793
(value.
_sign
<= char.MinValue) ? char.MinValue : (char)value.
_sign
;
4834
actualResult = (value.
_sign
>= short.MaxValue) ? short.MaxValue :
4835
(value.
_sign
<= short.MinValue) ? short.MinValue : (short)value.
_sign
;
4851
actualResult = (value.
_sign
>= int.MaxValue) ? int.MaxValue :
4852
(value.
_sign
<= int.MinValue) ? int.MinValue : value.
_sign
;
4895
actualResult = (value.
_sign
>= sbyte.MaxValue) ? sbyte.MaxValue :
4896
(value.
_sign
<= sbyte.MinValue) ? sbyte.MinValue : (sbyte)value.
_sign
;
4918
actualResult = (value.
_sign
>= ushort.MaxValue) ? ushort.MaxValue :
4919
(value.
_sign
<= ushort.MinValue) ? ushort.MinValue : (ushort)value.
_sign
;
4981
actualResult = (byte)value.
_sign
;
5004
actualResult = (char)value.
_sign
;
5045
actualResult = (short)value.
_sign
;
5061
actualResult = value.
_sign
;
5101
actualResult = value.
_sign
;
5158
actualResult = (Int128)(long)value.
_sign
;
5181
actualResult = value.
_sign
;
5203
actualResult = (sbyte)value.
_sign
;
5232
actualResult = (ushort)value.
_sign
;
5255
actualResult = (uint)value.
_sign
;
5295
actualResult = (ulong)value.
_sign
;
5352
actualResult = (UInt128)(Int128)(long)value.
_sign
;
5375
actualResult = (nuint)value.
_sign
;
5428
return new BigInteger((nint)value.
_sign
>>> smallShift);
5442
bool neg = value.
_sign
< 0;
5529
return new BigInteger(value.
_sign
>> 31, null);