本文整理汇总了C#中Microsoft.Scripting.Math.BigInteger.IsNegative方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.IsNegative方法的具体用法?C# BigInteger.IsNegative怎么用?C# BigInteger.IsNegative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Math.BigInteger
的用法示例。
在下文中一共展示了BigInteger.IsNegative方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToBinary
private static string ToBinary(BigInteger val, bool includeType, bool lowercase) {
Debug.Assert(!val.IsNegative());
string digits;
digits = ToDigits(val, 2, lowercase);
if (includeType) {
digits = (lowercase ? "0b" : "0B") + digits;
}
return digits;
}
示例2: ShiftOverflowCheck
/// <summary>
/// Test for shift overflow on negative BigIntegers
/// </summary>
/// <param name="self">Value before shifting</param>
/// <param name="result">Value after shifting</param>
/// <returns>-1 if we overflowed, otherwise result</returns>
/// <remarks>
/// Negative Bignums are supposed to look like they are stored in 2s complement infinite bit string,
/// a negative number should always have spare 1s available for on the left hand side for right shifting.
/// E.g. 8 == ...0001000; -8 == ...1110111, where the ... means that the left hand value is repeated indefinitely.
/// The test here checks whether we have overflowed into the infinite 1s.
/// [Arguably this should get factored into the BigInteger class.]
/// </remarks>
private static BigInteger/*!*/ ShiftOverflowCheck(BigInteger/*!*/ self, BigInteger/*!*/ result) {
if (self.IsNegative() && result.IsZero()) {
return -1;
}
return result;
}
示例3: RightShift
public static object/*!*/ RightShift(BigInteger/*!*/ self, [NotNull]BigInteger/*!*/ other) {
if (self.IsNegative()) {
return -1;
}
return 0;
}
示例4: ConvertBignumToFloat
public static double ConvertBignumToFloat(BigInteger/*!*/ value) {
double result;
return value.TryToFloat64(out result) ? result : (value.IsNegative() ? Double.NegativeInfinity : Double.PositiveInfinity);
}
示例5: RightShift
public static object RightShift(BigInteger/*!*/ self, [NotNull]BigInteger/*!*/ other)
{
return self.IsNegative() ? ClrInteger.MinusOne : ClrInteger.Zero;
}