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