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)
634TChar.CastFrom(value._sign >= 0 ? '0' : (format == 'x') ? 'f' : 'F'), 676int charsInHighByte = 9 - byte.LeadingZeroCount(value._sign >= 0 ? highByte : (byte)~highByte); 722sb.Append(TChar.CastFrom(value._sign >= 0 ? '0' : '1'), digits - charsForBits); 799spanSuccess = value._sign.TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(destination), out charsWritten, formatSpan, info); 804spanSuccess = value._sign.TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(destination), out charsWritten, formatSpan, info); 814return 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); 866return new BigInteger((int)NumericsHelpers.Abs(value._sign), value._bits); 902(int q, int r) = Math.DivRem(dividend._sign, divisor._sign); 924BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient, out nuint rest); 926remainder = dividend._sign < 0 ? -(long)rest : (long)rest; 927return new BigInteger(quotient, (dividend._sign < 0) ^ (divisor._sign < 0)); 947remainder = new(rest, dividend._sign < 0); 948BigInteger result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0)); 969if (value._sign < 0 || baseValue == 1.0D) 986return Math.Log(value._sign, baseValue); 1036return BigIntegerCalculator.Gcd(NumericsHelpers.Abs(left._sign), NumericsHelpers.Abs(right._sign)); 1042return left._sign != 0 1043? BigIntegerCalculator.Gcd(right._bits, NumericsHelpers.Abs(left._sign)) 1050return right._sign != 0 1051? BigIntegerCalculator.Gcd(left._bits, NumericsHelpers.Abs(right._sign)) 1120nuint bitsResult = trivialValue && trivialExponent ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1121trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, NumericsHelpers.Abs(modulus._sign)) : 1122trivialExponent ? BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1123BigIntegerCalculator.Pow(value._bits!, exponent._bits!, NumericsHelpers.Abs(modulus._sign)); 1125result = value._sign < 0 && !exponent.IsEven ? -(long)bitsResult : (long)bitsResult; 1135BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1139BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, modulus._bits!, bits); 1144BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1151result = new BigInteger(bits, value._sign < 0 && !exponent.IsEven); 1180if (value._sign == 1) 1185if (value._sign == -1) 1190if (value._sign == 0) 1198BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), power, bits); 1199result = new BigInteger(bits, value._sign < 0 && (exponent & 1) != 0); 1208result = new BigInteger(bits, value._sign < 0 && (exponent & 1) != 0); 1219return _sign; 1224hash.Add(_sign); 1237return _sign == other; 1242if ((_sign ^ other) < 0 || (cu = _bits.Length) > maxLimbs) 1264if (_sign < 0) 1271return (ulong)_sign == other; 1295return _sign == other._sign && _bits.AsSpan().SequenceEqual(other._bits); 1302return ((long)_sign).CompareTo(other); 1307if ((_sign ^ other) < 0 || (cu = _bits.Length) > maxLimbs) 1309return _sign; 1326return _sign * uuTmp.CompareTo(uu); 1332if (_sign < 0) 1339return ((ulong)(uint)_sign).CompareTo(other); 1367if ((_sign ^ other._sign) < 0) 1370return _sign < 0 ? -1 : +1; 1377other._bits is not null ? -other._sign : 1378_sign < other._sign ? -1 : 1379_sign > other._sign ? +1 : 1385return _sign; 1389return _sign < 0 ? -bitsResult : bitsResult; 1519int sign = _sign; 1728Debug.Assert(_bits is null || _sign == 0 ? buffer.Length == 2 : buffer.Length >= _bits.Length + 1); 1734buffer[0] = (nuint)_sign; 1735highLimb = (_sign < 0) ? nuint.MaxValue : 0; 1741if (_sign == -1) 1854string signStr = _sign < 0 ? NumberFormatInfo.CurrentInfo.NegativeSign : ""; 1932return (long)left._sign - right._sign; 1935return left._sign < 0 != right._sign < 0 1936? Add(left._bits, left._sign, right._bits, -right._sign) 1937: Subtract(left._bits, left._sign, right._bits, right._sign); 2010return value._sign; 2018int sign = value._sign; 2081return value._sign; 2090if (value._sign > 0) 2108return value._sign; 2131long ll = value._sign > 0 ? (long)uu : -(long)uu; 2132if ((ll > 0 && value._sign > 0) || (ll < 0 && value._sign < 0)) 2148return value._sign; 2179Int128 ll = (value._sign > 0) ? (Int128)uu : -(Int128)uu; 2181if (((ll > 0) && (value._sign > 0)) || ((ll < 0) && (value._sign < 0))) 2208return checked((uint)value._sign); 2212return value._bits.Length <= 1 && value._sign >= 0 2223return checked((ulong)value._sign); 2228if (len > maxLimbs || value._sign < 0) 2251return checked((UInt128)value._sign); 2257if ((len > maxLimbs) || (value._sign < 0)) 2484left._bits is null && right._bits is null ? (BigInteger)(left._sign & right._sign) : 2500? (BigInteger)(left._sign | right._sign) 2506? (BigInteger)(left._sign ^ right._sign) 2522int zLen = (left._sign < 0 || right._sign < 0) 2555left._bits, left._sign, 2556right._bits, right._sign, 2587return LeftShift(value._sign, digitShift, smallShift); 2621return new BigInteger(value._sign, z); 2689return new BigInteger(value._sign >> smallShift, null); 2700return new BigInteger(value._sign >> 31, null); 2710bool neg = value._sign < 0; 2734return ~value._sign; // implicit int -> BigInteger handles int.MinValue 2739if (value._sign >= 0) 2762public static BigInteger operator -(BigInteger value) => new BigInteger(-value._sign, value._bits); 2770return (long)value._sign + 1; 2775if (value._sign >= 0) 2800return (long)value._sign - 1; 2805if (value._sign >= 0) 2830return (long)left._sign + right._sign; 2833return left._sign < 0 != right._sign < 0 2834? Subtract(left._bits, left._sign, right._bits, -right._sign) 2835: Add(left._bits, left._sign, right._bits, right._sign); 2840? (BigInteger)((long)left._sign * right._sign) 2841: Multiply(left._bits, left._sign, right._bits, right._sign); 2905return dividend._sign / divisor._sign; 2923BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient); 2925BigInteger result = new BigInteger(quotient, (dividend._sign < 0) ^ (divisor._sign < 0)); 2944BigInteger result = new(quotient, (dividend._sign < 0) ^ (divisor._sign < 0)); 2959return dividend._sign % divisor._sign; 2972nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor._sign)); 2973return dividend._sign < 0 ? -(long)remainder : (long)remainder; 2987BigInteger result = new(bits, dividend._sign < 0); 3075int sign = _sign; 3115Debug.Assert(_sign is 1 or -1); 3128Debug.Assert(_sign > int.MinValue); 3156return uint.Log10((uint)value._sign); 3185return nint.LeadingZeroCount(value._sign); 3191return (value._sign >= 0) 3201return nint.PopCount(value._sign); 3206if (value._sign >= 0) 3256bool neg = value._sign < 0; 3260nuint rs = BitOperations.RotateLeft((nuint)value._sign, rotateAmount); 3277bool neg = value._sign < 0; 3281nuint rs = BitOperations.RotateRight((nuint)value._sign, rotateAmount); 3348return nint.TrailingZeroCount(value._sign); 3390int value = _sign; 3397if (_sign >= 0) 3434BinaryPrimitives.WriteIntPtrBigEndian(destination, _sign); 3436else if (_sign >= 0) 3512BinaryPrimitives.WriteIntPtrLittleEndian(destination, _sign); 3514else if (_sign >= 0) 3588if (_sign < 0) 3631? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1)) 3675nint currentSign = value._sign; 3682nint targetSign = sign._sign; 3702? value._sign > 0 ? 1 3703: (value._sign < 0 ? -1 : 0) : value._sign; 3780? (value._sign & 1) == 0 3802return value._sign < 0; 3815? (value._sign & 1) != 0 3822return value._sign >= 0; 3837return value._sign == 0; 4371actualResult = (value._sign >= byte.MaxValue) ? byte.MaxValue : 4372(value._sign <= byte.MinValue) ? byte.MinValue : (byte)value._sign; 4388actualResult = (value._sign >= char.MaxValue) ? char.MaxValue : 4389(value._sign <= char.MinValue) ? char.MinValue : (char)value._sign; 4430actualResult = (value._sign >= short.MaxValue) ? short.MaxValue : 4431(value._sign <= short.MinValue) ? short.MinValue : (short)value._sign; 4447actualResult = (value._sign >= int.MaxValue) ? int.MaxValue : 4448(value._sign <= int.MinValue) ? int.MinValue : value._sign; 4491actualResult = (value._sign >= sbyte.MaxValue) ? sbyte.MaxValue : 4492(value._sign <= sbyte.MinValue) ? sbyte.MinValue : (sbyte)value._sign; 4514actualResult = (value._sign >= ushort.MaxValue) ? ushort.MaxValue : 4515(value._sign <= ushort.MinValue) ? ushort.MinValue : (ushort)value._sign; 4577actualResult = (byte)value._sign; 4600actualResult = (char)value._sign; 4641actualResult = (short)value._sign; 4657actualResult = value._sign; 4697actualResult = value._sign; 4754actualResult = (Int128)(long)value._sign; 4777actualResult = value._sign; 4799actualResult = (sbyte)value._sign; 4828actualResult = (ushort)value._sign; 4851actualResult = (uint)value._sign; 4891actualResult = (ulong)value._sign; 4948actualResult = (UInt128)(Int128)(long)value._sign; 4971actualResult = (nuint)value._sign; 5024return new BigInteger((nint)value._sign >>> smallShift); 5038bool neg = value._sign < 0; 5125return new BigInteger(value._sign >> 31, null);