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