本文整理汇总了C#中BigDecimal.ToBigInteger方法的典型用法代码示例。如果您正苦于以下问题:C# BigDecimal.ToBigInteger方法的具体用法?C# BigDecimal.ToBigInteger怎么用?C# BigDecimal.ToBigInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigDecimal
的用法示例。
在下文中一共展示了BigDecimal.ToBigInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBigDecimal
// Only call this from a constructor!
private void SetBigDecimal(BigDecimal value)
{
bigDecimal = value;
if (bigDecimal.Scale == 0) {
BigInteger bint = value.ToBigInteger();
int bit_count = bint.BitLength;
if (bit_count < 30) {
long_representation = bint.ToInt64();
byteCount = 4;
} else if (bit_count < 60) {
long_representation = bint.ToInt64();
byteCount = 8;
}
}
}
示例2: ToBigInteger
public void ToBigInteger()
{
BigDecimal sub1 = BigDecimal.Parse("-29830.989");
BigInteger result = sub1.ToBigInteger();
Assert.IsTrue(result.ToString().Equals("-29830"), "the bigInteger equivalent of -29830.989 is wrong");
sub1 = new BigDecimal(-2837E10);
result = sub1.ToBigInteger();
Assert.IsTrue(result.ToDouble() == -2837E10, "the bigInteger equivalent of -2837E10 is wrong");
sub1 = new BigDecimal(2.349E-10);
result = sub1.ToBigInteger();
Assert.IsTrue(result.Equals(BigInteger.Zero), "the bigInteger equivalent of 2.349E-10 is wrong");
sub1 = new BigDecimal(value2, 6);
result = sub1.ToBigInteger();
Assert.IsTrue(result.ToString().Equals("12334"), "the bigInteger equivalent of 12334.560000 is wrong");
}