public void EqualsObject()
        {
            BigDecimal equal1 = new BigDecimal(1.00D);
            BigDecimal equal2 = BigDecimal.Parse("1.0");

            Assert.IsFalse(equal1.Equals(equal2), "1.00 and 1.0 should not be equal");
            equal2 = new BigDecimal(1.01D);
            Assert.IsFalse(equal1.Equals(equal2), "1.00 and 1.01 should not be equal");
            equal2 = BigDecimal.Parse("1.00");
            Assert.IsFalse(equal1.Equals(equal2), "1.00D and 1.00 should not be equal");
            BigInteger val = BigInteger.Parse("100");

            equal1 = BigDecimal.Parse("1.00");
            equal2 = new BigDecimal(val, 2);
            Assert.IsTrue(equal1.Equals(equal2), "1.00(string) and 1.00(bigInteger) should be equal");
            equal1 = new BigDecimal(100D);
            equal2 = BigDecimal.Parse("2.34576");
            Assert.IsFalse(equal1.Equals(equal2), "100D and 2.34576 should not be equal");
            Assert.IsFalse(equal1.Equals("23415"), "bigDecimal 100D does not equal string 23415");
        }
        public void SubtractBigDecimal()
        {
            BigDecimal sub1   = BigDecimal.Parse("13948");
            BigDecimal sub2   = BigDecimal.Parse("2839.489");
            BigDecimal result = sub1.Subtract(sub2);

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

            Assert.IsTrue(result2.ToString().Equals("-11108.511") && result2.Scale == 3, "2839.489 - 13948 is wrong");
            Assert.IsTrue(result.Equals(result2.Negate()), "13948 - 2839.489 is not the negative of 2839.489 - 13948");
            sub1   = new BigDecimal(value, 1);
            sub2   = BigDecimal.Parse("0");
            result = sub1.Subtract(sub2);
            Assert.IsTrue(result.Equals(sub1), "1234590.8 - 0 is wrong");
            sub1   = new BigDecimal(1.234E-03);
            sub2   = new BigDecimal(3.423E-10);
            result = sub1.Subtract(sub2);
            Assert.IsTrue(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 = sub1.Subtract(sub2);
            Assert.IsTrue(result.ToDouble() == 0.0, "1234.0123 - 1234.0123000 is wrong, " + result.ToDouble());
        }
        public void TestGetHashCode()
        {
            // anything that is equal must have the same hashCode
            BigDecimal hash  = BigDecimal.Parse("1.00");
            BigDecimal hash2 = new BigDecimal(1.00D);

            Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
                          "the hashCode of 1.00 and 1.00D is equal");
            hash2 = BigDecimal.Parse("1.0");
            Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
                          "the hashCode of 1.0 and 1.00 is equal");
            BigInteger val = BigInteger.Parse("100");

            hash2 = new BigDecimal(val, 2);
            Assert.IsTrue(hash.GetHashCode() == hash2.GetHashCode() && hash.Equals(hash2),
                          "hashCode of 1.00 and 1.00(bigInteger) is not equal");
            hash  = new BigDecimal(value, 2);
            hash2 = BigDecimal.Parse("-1233456.0000");
            Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
                          "hashCode of 123459.08 and -1233456.0000 is not equal");
            hash2 = new BigDecimal(value.Negate(), 2);
            Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
                          "hashCode of 123459.08 and -123459.08 is not equal");
        }
        public void MovePointRightI()
        {
            BigDecimal movePtRight  = BigDecimal.Parse("-1.58796521458");
            BigDecimal alreadyMoved = movePtRight.MovePointRight(8);

            Assert.IsTrue(alreadyMoved.Scale == 3 && alreadyMoved.ToString().Equals("-158796521.458"),
                          "move point right 8 failed");
            movePtRight  = new BigDecimal(value, 2);
            alreadyMoved = movePtRight.MovePointRight(4);
            Assert.IsTrue(alreadyMoved.Scale == 0 && alreadyMoved.ToString().Equals("1234590800"), "move point right 4 failed");
            movePtRight  = new BigDecimal(134E12);
            alreadyMoved = movePtRight.MovePointRight(2);
            Assert.IsTrue(alreadyMoved.Scale == 0 && alreadyMoved.ToString().Equals("13400000000000000"),
                          "move point right 2 failed");
            movePtRight  = new BigDecimal(-3.4E-10);
            alreadyMoved = movePtRight.MovePointRight(5);
            Assert.IsTrue(alreadyMoved.Scale == movePtRight.Scale - 5 && alreadyMoved.ToDouble() == -0.000034,
                          "move point right 5 failed");
            alreadyMoved = alreadyMoved.MovePointRight(-5);
            Assert.IsTrue(alreadyMoved.Equals(movePtRight), "move point right -5 failed");
        }