• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BigDecimal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Move

 public override void Move(int moveX, int moveY)
 {
     TerminateThreads();
     xorigin -= (BigDecimal)(moveX) * (xmax - xmin) / (BigDecimal)screenWidth;
     yorigin -= (BigDecimal)(moveY) * (ymax - ymin) / (BigDecimal)screenHeight;
     Draw(numIterations, numThreads);
 }
开发者ID:dbrant,项目名称:MandelbrotCsharp,代码行数:7,代码来源:SimpleBigIntRenderer.cs


示例2: TestBigDecimal

 public void TestBigDecimal() {
    BigDecimal decimal = new BigDecimal("1.1");
    BigDecimalTransform format = new BigDecimalTransform();
    String value = format.write(decimal);
    BigDecimal copy = format.read(value);
    AssertEquals(decimal, copy);
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:7,代码来源:BigDecimalTransformTest.cs


示例3: PayPalItem

		public PayPalItem (string name, BigDecimal price, string currency)
		{
			Name = name;
			//Quantity = quantity;
			Price = price;
			Currency = currency;
			//SKU = sku;
		}
开发者ID:15mgm15,项目名称:PayPal.Forms,代码行数:8,代码来源:PayPalItem.cs


示例4: Add

 public void Add(string a, int aScale, string b, int bScale, string c, int cScale)
 {
     BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
     BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
     BigDecimal result = aNumber.Add(bNumber);
     Assert.AreEqual(c, result.ToString(), "incorrect value");
     Assert.AreEqual(cScale, result.Scale, "incorrect scale");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:8,代码来源:BigDecimalArithmeticTest.cs


示例5: Calculate

 public virtual Number Calculate(BigDecimal num)
 {
     if (num == null)
     {
         return -0;
     }
     return num.Negate();
 }
开发者ID:tupunco,项目名称:Tup.Cobar4Net,代码行数:8,代码来源:MinusExpression.cs


示例6: EBig

        /// <summary>
        /// The mathematical constant e.
        /// </summary>
        /// <param name="precision">The precision.</param>
        /// <returns>The mathematical constant e.</returns>
        public static BigDecimal EBig(int precision)
        {
            if (_EBig.Precision < precision)
            {
                _EBig = BigDecimal.Exp(BigDecimal.One.WithPrecision(precision + 10));
            }

            return _EBig.WithPrecision(precision);
        }
开发者ID:jamiees2,项目名称:Pie,代码行数:14,代码来源:Constants.cs


示例7: AddWithContext

 public void AddWithContext(string a, int aScale, string b, int bScale, string c, int cScale, int precision, RoundingMode mode)
 {
     BigDecimal aNumber = new BigDecimal(BigInteger.Parse(a), aScale);
     BigDecimal bNumber = new BigDecimal(BigInteger.Parse(b), bScale);
     MathContext mc = new MathContext(precision, mode);
     BigDecimal result = aNumber.Add(bNumber, mc);
     Assert.AreEqual(c, result.ToString(), "incorrect value");
     Assert.AreEqual(cScale, result.Scale, "incorrect scale");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:9,代码来源:BigDecimalArithmeticTest.cs


示例8: Abs

 public void Abs()
 {
     BigDecimal big = BigDecimal.Parse("-1234");
     BigDecimal bigabs = big.Abs();
     Assert.IsTrue(bigabs.ToString().Equals("1234"), "the absolute value of -1234 is not 1234");
     big = new BigDecimal(BigInteger.Parse("2345"), 2);
     bigabs = big.Abs();
     Assert.IsTrue(bigabs.ToString().Equals("23.45"), "the absolute value of 23.45 is not 23.45");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:9,代码来源:BigDecimalTest.cs


示例9: CompareToBigDecimal

 public void CompareToBigDecimal()
 {
     BigDecimal comp1 = BigDecimal.Parse("1.00");
     BigDecimal comp2 = new BigDecimal(1.000000D);
     Assert.IsTrue(comp1.CompareTo(comp2) == 0, "1.00 and 1.000000 should be equal");
     BigDecimal comp3 = BigDecimal.Parse("1.02");
     Assert.IsTrue(comp3.CompareTo(comp1) == 1, "1.02 should be bigger than 1.00");
     BigDecimal comp4 = new BigDecimal(0.98D);
     Assert.IsTrue(comp4.CompareTo(comp1) == -1, "0.98 should be less than 1.00");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:10,代码来源:BigDecimalTest.cs


示例10: AddBigDecimal

 public void AddBigDecimal()
 {
     BigDecimal add1 = BigDecimal.Parse("23.456");
     BigDecimal add2 = BigDecimal.Parse("3849.235");
     BigDecimal sum = add1.Add(add2);
     Assert.IsTrue(sum.UnscaledValue.ToString().Equals("3872691") && sum.Scale == 3,
                   "the sum of 23.456 + 3849.235 is wrong");
     Assert.IsTrue(sum.ToString().Equals("3872.691"), "the sum of 23.456 + 3849.235 is not printed correctly");
     BigDecimal add3 = new BigDecimal(12.34E02D);
     Assert.IsTrue((add1.Add(add3)).ToString().Equals("1257.456"), "the sum of 23.456 + 12.34E02 is not printed correctly");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:11,代码来源:BigDecimalTest.cs


示例11: Should_Allow_Custom_Primitive_Serializers

 public void Should_Allow_Custom_Primitive_Serializers()
 {
     var serializer = new Serializer(4, new [] {new BigDecimalSerializer()});
     var value = new BigDecimal(5, 1);
     var buffer = serializer.Serialize(value);
     CollectionAssert.AreEqual(new byte[] { 0, 0, 0, 5, 1 }, buffer);
     var deserializedValue = serializer.Deserialize(buffer, ColumnTypeCode.Decimal, null);
     Assert.IsInstanceOf<BigDecimal>(deserializedValue);
     var deserializedDecimal = (BigDecimal) deserializedValue;
     Assert.AreEqual("0.00001", deserializedDecimal.ToString());
     Assert.AreEqual(value.Scale, deserializedDecimal.Scale);
     Assert.AreEqual(value.UnscaledValue, deserializedDecimal.UnscaledValue);
     //Check that other serializers are still working
     CollectionAssert.AreEqual(new byte[] { 0, 0, 0, 10 }, serializer.Serialize(10));
     CollectionAssert.AreEqual(new byte[] { 0x61 }, serializer.Serialize("a"));
 }
开发者ID:alprema,项目名称:csharp-driver,代码行数:16,代码来源:CustomTypeSerializerTests.cs


示例12: Zoom

        public override void Zoom(int posX, int posY, double factor)
        {
            BigDecimal xpos = xmin + ((BigDecimal)posX * (xmax - xmin) / (BigDecimal)screenWidth);
            BigDecimal ypos = ymin + ((BigDecimal)posY * (ymax - ymin) / (BigDecimal)screenHeight);
            BigDecimal xOffsetRatio = (xpos - xmin) / (xmax - xmin);
            BigDecimal yOffsetRatio = (ypos - ymin) / (ymax - ymin);

            BigDecimal newXextent = (xmax - xmin);
            newXextent *= factor;

            BigDecimal newYextent = (ymax - ymin);
            newYextent *= factor;

            TerminateThreads();
            xextent = newXextent;
            xorigin = xpos - xextent * xOffsetRatio;
            yorigin = ypos - newYextent * yOffsetRatio;
            Draw(numIterations, numThreads);
        }
开发者ID:dbrant,项目名称:MandelbrotCsharp,代码行数:19,代码来源:SimpleBigIntRenderer.cs


示例13: 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


示例14: ConstructorDouble

 public void ConstructorDouble()
 {
     BigDecimal big = new BigDecimal(123E04);
     Assert.AreEqual("1230000", big.ToString(),
                     "the BigDecimal value taking a double argument is not initialized properly");
     big = new BigDecimal(1.2345E-12);
     Assert.AreEqual(1.2345E-12, big.ToDouble(), "the double representation is not correct");
     big = new BigDecimal(-12345E-3);
     Assert.AreEqual(-12.345, big.ToDouble(), "the double representation is not correct");
     big = new BigDecimal(5.1234567897654321e138);
     Assert.AreEqual(5.1234567897654321E138, big.ToDouble(), "the double representation is not correct");
     Assert.AreEqual(0, big.Scale, "the double representation is not correct");
     big = new BigDecimal(0.1);
     Assert.IsTrue(big.ToDouble() == 0.1, "the double representation of 0.1 bigDecimal is not correct");
     big = new BigDecimal(0.00345);
     Assert.IsTrue(big.ToDouble() == 0.00345, "the double representation of 0.00345 bigDecimal is not correct");
     // regression test for HARMONY-2429
     big = new BigDecimal(-0.0);
     Assert.IsTrue(big.Scale == 0, "the double representation of -0.0 bigDecimal is not correct");
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:20,代码来源:BigDecimalTest.cs


示例15: TestToString

		public void TestToString() {
			BigDecimal d;

			// integers
			d = new BigDecimal(0, 0);
			Assert.AreEqual("0.", d.ToString());

			d = new BigDecimal(1, 0);
			Assert.AreEqual("1.", d.ToString());

			// with decimal point inside number
			d = new BigDecimal(1234, 2);
			Assert.AreEqual("12.34", d.ToString());

			// with decimal point before number
			d = new BigDecimal(1, 2);
			Assert.AreEqual("0.01", d.ToString());

			// really big number, with decimal point
			d = new BigDecimal(BigInteger.Parse("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"), 20);
			Assert.AreEqual("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.12345678901234567890", d.ToString());
		}
开发者ID:GameMoney,项目名称:dotnet-big-decimal,代码行数:22,代码来源:TestDecimal.cs


示例16: getStuffToBuy

		/* 
    	 * This method shows use of optional payment details and item list.
     	*/
		private PayPalPayment getStuffToBuy(string paymentIntent) {
			//--- include an item list, payment amount details
			PayPalItem[] items =
			{
				new PayPalItem("sample item #1", new Java.Lang.Integer(2), new BigDecimal("87.50"), "USD",
					"sku-12345678"),
				new PayPalItem("free sample item #2", new Java.Lang.Integer(1), new BigDecimal("0.00"),
					"USD", "sku-zero-price"),
				new PayPalItem("sample item #3 with a longer name", new Java.Lang.Integer(6), new BigDecimal("37.99"),
					"USD", "sku-33333") 
			};
			BigDecimal subtotal = PayPalItem.GetItemTotal(items);
			BigDecimal shipping = new BigDecimal("7.21");
			BigDecimal tax = new BigDecimal("4.67");
			PayPalPaymentDetails paymentDetails = new PayPalPaymentDetails(shipping, subtotal, tax);
			BigDecimal amount = subtotal.Add(shipping).Add(tax);
			PayPalPayment payment = new PayPalPayment(amount, "USD", "sample item", paymentIntent);
			payment.Items(items).PaymentDetails(paymentDetails);

			//--- set other optional fields like invoice_number, custom field, and soft_descriptor
			payment.Custom("This is text that will be associated with the payment that the app can use.");

			return payment;
		}
开发者ID:15mgm15,项目名称:PayPal.Forms,代码行数:27,代码来源:PayPalManager.cs


示例17: Truncate

 public static BigDecimal/*!*/ Truncate(RubyContext/*!*/ context, BigDecimal/*!*/ self, [Optional]int n) {
     return BigDecimal.LimitPrecision(GetConfig(context), self, n, BigDecimal.RoundingModes.Down);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:BigDecimalOps.cs


示例18: IsFinite

 public static bool IsFinite(BigDecimal/*!*/ self) {
     return BigDecimal.IsFinite(self);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:BigDecimalOps.cs


示例19: Round

 public static BigDecimal/*!*/ Round(RubyContext/*!*/ context, BigDecimal/*!*/ self, [Optional]int n) {
     return BigDecimal.LimitPrecision(GetConfig(context), self, n, GetConfig(context).RoundingMode);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:BigDecimalOps.cs


示例20: Equal

 public static bool Equal(RubyContext/*!*/ context, BigDecimal/*!*/ self, double other) {
     return self.Equals(BigDecimal.Create(GetConfig(context), other));
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:BigDecimalOps.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BigEndianBinaryReader类代码示例发布时间:2022-05-24
下一篇:
C# BiCgStab类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap