本文整理汇总了C#中BigDecimal.DivideToIntegralValue方法的典型用法代码示例。如果您正苦于以下问题:C# BigDecimal.DivideToIntegralValue方法的具体用法?C# BigDecimal.DivideToIntegralValue怎么用?C# BigDecimal.DivideToIntegralValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigDecimal
的用法示例。
在下文中一共展示了BigDecimal.DivideToIntegralValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DivideToIntegralValueMathContextUp
public void DivideToIntegralValueMathContextUp()
{
String a = "3736186567876876578956958765675671119238118911893939591735";
int aScale = 45;
String b = "134432345432345748766876876723342238476237823787879183470";
int bScale = 70;
int precision = 32;
RoundingMode rm = RoundingMode.Up;
MathContext mc = new MathContext(precision, rm);
String c = "277923185514690367474770683";
int resScale = 0;
BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
BigDecimal result = aNumber.DivideToIntegralValue(bNumber, mc);
Assert.AreEqual(c, result.ToString(), "incorrect value");
Assert.AreEqual(resScale, result.Scale, "incorrect scale");
}
示例2: DivideToIntegralValueMathContextDown
public void DivideToIntegralValueMathContextDown()
{
String a = "3736186567876876578956958769675785435673453453653543654354365435675671119238118911893939591735";
int aScale = 45;
String b = "134432345432345748766876876723342238476237823787879183470";
int bScale = 70;
int precision = 75;
RoundingMode rm = RoundingMode.Down;
MathContext mc = new MathContext(precision, rm);
String c = "2.7792318551469036747477068339450205874992634417590178670822889E+62";
int resScale = -1;
BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
BigDecimal result = aNumber.DivideToIntegralValue(bNumber, mc);
Assert.AreEqual(c, result.ToString(), "incorrect value");
Assert.AreEqual(resScale, result.Scale, "incorrect scale");
}