本文整理汇总了C#中System.Number.ConvertCast方法的典型用法代码示例。如果您正苦于以下问题:C# Number.ConvertCast方法的具体用法?C# Number.ConvertCast怎么用?C# Number.ConvertCast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Number
的用法示例。
在下文中一共展示了Number.ConvertCast方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Divide
Number Divide(Number n, bool allowFraction)
{
var longNumber = n.ConvertCast<LongIntegerNumber>();
bool isResultNegative = isNegative ^ longNumber.isNegative;
if(allowFraction && CompareCore(parts, longNumber.parts) < 0)
return FractionNumber.Create(new LongIntegerNumber(parts, isResultNegative), new LongIntegerNumber(longNumber.parts, false)); ;
return DivieCore(parts, longNumber.parts, isResultNegative, allowFraction);
}
示例2: Subtract
protected override Number Subtract(Number n)
{
var longNumber = n.ConvertCast<LongIntegerNumber>();
return Add(new LongIntegerNumber(longNumber.parts, !longNumber.isNegative));
}
示例3: Power
protected override Number Power(Number n)
{
var b = n.ConvertCast<LongIntegerNumber>();
return FastPower(this, b);
}
示例4: Multiply
protected override Number Multiply(Number n)
{
var longNumber = n.ConvertCast<LongIntegerNumber>();
return new LongIntegerNumber(MultiplyCore(this.parts, longNumber.parts), isNegative ^ longNumber.isNegative);
}
示例5: Add
protected override Number Add(Number n)
{
var longNumber = n.ConvertCast<LongIntegerNumber>();
if(!isNegative && !longNumber.isNegative)
return AddCore(longNumber);
if(longNumber.isNegative) {
var invertedRight = new LongIntegerNumber(longNumber.parts, false);
if(this < invertedRight)
return new LongIntegerNumber(invertedRight.Subtract(this).ConvertCast<LongIntegerNumber>().parts, true);
} else {
var invertedLeft = new LongIntegerNumber(this.parts, false);
if(longNumber < invertedLeft)
return new LongIntegerNumber(invertedLeft.Subtract(longNumber).ConvertCast<LongIntegerNumber>().parts, true);
}
return AddCore(longNumber);
}
示例6: Modulo
internal LongIntegerNumber Modulo(Number n)
{
var longNumber = n.ConvertCast<LongIntegerNumber>();
LongIntegerNumber remain = Zero;
DivieImpl(parts, longNumber.parts, out remain);
return remain;
}