コード例 #1
0
        public void ValueOfJ()
        {
            BigDecimal valueOfL = BigDecimal.ValueOf(9223372036854775806L);

            Assert.IsTrue(valueOfL.UnscaledValue.ToString().Equals("9223372036854775806") && valueOfL.Scale == 0,
                          "the bigDecimal equivalent of 9223372036854775806 is wrong");
            Assert.IsTrue(valueOfL.ToString().Equals("9223372036854775806"),
                          "the ToString representation of 9223372036854775806 is wrong");
            valueOfL = BigDecimal.ValueOf(0L);
            Assert.IsTrue(valueOfL.UnscaledValue.ToString().Equals("0") && valueOfL.Scale == 0,
                          "the bigDecimal equivalent of 0 is wrong");
        }
コード例 #2
0
        public void ValueOfJI()
        {
            BigDecimal valueOfJI = BigDecimal.ValueOf(9223372036854775806L, 5);

            Assert.IsTrue(valueOfJI.UnscaledValue.ToString().Equals("9223372036854775806") && valueOfJI.Scale == 5,
                          "the bigDecimal equivalent of 92233720368547.75806 is wrong");
            Assert.IsTrue(valueOfJI.ToString().Equals("92233720368547.75806"),
                          "the ToString representation of 9223372036854775806 is wrong");
            valueOfJI = BigDecimal.ValueOf(1234L, 8);
            Assert.IsTrue(valueOfJI.UnscaledValue.ToString().Equals("1234") && valueOfJI.Scale == 8,
                          "the bigDecimal equivalent of 92233720368547.75806 is wrong");
            Assert.IsTrue(valueOfJI.ToString().Equals("0.00001234"),
                          "the ToString representation of 9223372036854775806 is wrong");
            valueOfJI = BigDecimal.ValueOf(0, 3);
            Assert.IsTrue(valueOfJI.UnscaledValue.ToString().Equals("0") && valueOfJI.Scale == 3,
                          "the bigDecimal equivalent of 92233720368547.75806 is wrong");
            Assert.IsTrue(valueOfJI.ToString().Equals("0.000"), "the ToString representation of 9223372036854775806 is wrong");
        }