当前位置: 首页>>代码示例>>C#>>正文


C# BigDecimal.DivideAndRemainder方法代码示例

本文整理汇总了C#中BigDecimal.DivideAndRemainder方法的典型用法代码示例。如果您正苦于以下问题:C# BigDecimal.DivideAndRemainder方法的具体用法?C# BigDecimal.DivideAndRemainder怎么用?C# BigDecimal.DivideAndRemainder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigDecimal的用法示例。


在下文中一共展示了BigDecimal.DivideAndRemainder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DivideAndRemainder1

 public void DivideAndRemainder1()
 {
     String a = "3736186567876876578956958765675671119238118911893939591735";
     int aScale = 45;
     String b = "134432345432345748766876876723342238476237823787879183470";
     int bScale = 70;
     String res = "277923185514690367474770683";
     int resScale = 0;
     String rem = "1.3032693871288309587558885943391070087960319452465789990E-15";
     int remScale = 70;
     BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
     BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
     BigDecimal remainder;
     BigDecimal quotient = aNumber.DivideAndRemainder(bNumber, out remainder);
     Assert.AreEqual(res, quotient.ToString(), "incorrect quotient value");
     Assert.AreEqual(resScale, quotient.Scale, "incorrect quotient scale");
     Assert.AreEqual(rem, remainder.ToString(), "incorrect remainder value");
     Assert.AreEqual(remScale, remainder.Scale, "incorrect remainder scale");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:19,代码来源:BigDecimalArithmeticTest.cs

示例2: DivideAndRemainder2

 public void DivideAndRemainder2()
 {
     String a = "3736186567876876578956958765675671119238118911893939591735";
     int aScale = -45;
     String b = "134432345432345748766876876723342238476237823787879183470";
     int bScale = 70;
     String res = "2779231855146903674747706830969461168692256919247547952" +
                  "2608549363170374005512836303475980101168105698072946555" +
                  "6862849";
     int resScale = 0;
     String rem = "3.4935796954060524114470681810486417234751682675102093970E-15";
     int remScale = 70;
     BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
     BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
     BigDecimal remainder;
     BigDecimal quotient = aNumber.DivideAndRemainder(bNumber, out remainder);
     Assert.AreEqual(res, quotient.ToString(), "incorrect quotient value");
     Assert.AreEqual(resScale, quotient.Scale, "incorrect quotient scale");
     Assert.AreEqual(rem, remainder.ToString(), "incorrect remainder value");
     Assert.AreEqual(remScale, remainder.Scale, "incorrect remainder scale");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:21,代码来源:BigDecimalArithmeticTest.cs

示例3: DivideAndRemainderMathContextDown

 public void DivideAndRemainderMathContextDown()
 {
     String a = "3736186567876876578956958765675671119238118911893939591735";
     int aScale = 45;
     String b = "134432345432345748766876876723342238476237823787879183470";
     int bScale = 20;
     int precision = 15;
     RoundingMode rm = RoundingMode.Down;
     MathContext mc = new MathContext(precision, rm);
     String res = "0E-25";
     int resScale = 25;
     String rem = "3736186567876.876578956958765675671119238118911893939591735";
     int remScale = 45;
     BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
     BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
     BigDecimal remainder;
     BigDecimal quotient = aNumber.DivideAndRemainder(bNumber, mc, out remainder);
     Assert.AreEqual(res, quotient.ToString(), "incorrect quotient value");
     Assert.AreEqual(resScale, quotient.Scale, "incorrect quotient scale");
     Assert.AreEqual(rem, remainder.ToString(), "incorrect remainder value");
     Assert.AreEqual(remScale, remainder.Scale, "incorrect remainder scale");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:22,代码来源:BigDecimalArithmeticTest.cs


注:本文中的BigDecimal.DivideAndRemainder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。