public void SubtractBigDecimal()
        {
            BigDecimal sub1   = BigDecimal.Parse("13948");
            BigDecimal sub2   = BigDecimal.Parse("2839.489");
            BigDecimal result = BigMath.Subtract(sub1, sub2);

            Assert.True(result.ToString().Equals("11108.511") && result.Scale == 3, "13948 - 2839.489 is wrong: " + result);
            BigDecimal result2 = BigMath.Subtract(sub2, sub1);

            Assert.True(result2.ToString().Equals("-11108.511") && result2.Scale == 3, "2839.489 - 13948 is wrong");
            Assert.True(result.Equals(-result2), "13948 - 2839.489 is not the negative of 2839.489 - 13948");
            sub1   = new BigDecimal(value, 1);
            sub2   = BigDecimal.Parse("0");
            result = BigMath.Subtract(sub1, sub2);
            Assert.True(result.Equals(sub1), "1234590.8 - 0 is wrong");
            sub1   = new BigDecimal(1.234E-03);
            sub2   = new BigDecimal(3.423E-10);
            result = BigMath.Subtract(sub1, sub2);
            Assert.True(result.ToDouble() == 0.0012339996577, "1.234E-03 - 3.423E-10 is wrong, " + result.ToDouble());
            sub1   = new BigDecimal(1234.0123);
            sub2   = new BigDecimal(1234.0123000);
            result = BigMath.Subtract(sub1, sub2);
            Assert.True(result.ToDouble() == 0.0, "1234.0123 - 1234.0123000 is wrong, " + result.ToDouble());
        }
Beispiel #2
0
 public static BigInteger operator -(BigInteger a, BigInteger b)
 {
     return(BigMath.Subtract(a, b));
 }