Home
last modified time | relevance | path

Searched refs:BigDecimal (Results 1 – 25 of 89) sorted by relevance

1234

/libcore/ojluni/src/test/java/math/BigDecimal/
DStrippingZerosTest.java23 package test.java.math.BigDecimal;
44 BigDecimal [][] testCases = { in testStrippingZeros()
45 {new BigDecimal("1.00000"), new BigDecimal("1")}, in testStrippingZeros()
46 {new BigDecimal("1.000"), new BigDecimal("1")}, in testStrippingZeros()
47 {new BigDecimal("1"), new BigDecimal("1")}, in testStrippingZeros()
48 {new BigDecimal("0.1234"), new BigDecimal("0.1234")}, in testStrippingZeros()
49 {new BigDecimal("0.12340"), new BigDecimal("0.1234")}, in testStrippingZeros()
50 {new BigDecimal("0.12340000000"), new BigDecimal("0.1234")}, in testStrippingZeros()
51 {new BigDecimal("1234.5678"), new BigDecimal("1234.5678")}, in testStrippingZeros()
52 {new BigDecimal("1234.56780"), new BigDecimal("1234.5678")}, in testStrippingZeros()
[all …]
DAddTests.java23 package test.java.math.BigDecimal;
33 import static java.math.BigDecimal.*;
53 BigDecimal[] bd1 = { in simpleTests()
54 new BigDecimal(new BigInteger("7812404666936930160"), 11), in simpleTests()
55 new BigDecimal(new BigInteger("7812404666936930160"), 12), in simpleTests()
56 new BigDecimal(new BigInteger("7812404666936930160"), 13), in simpleTests()
58 BigDecimal bd2 = new BigDecimal(new BigInteger("2790000"), 1); in simpleTests()
59 BigDecimal[] expectedResult = { in simpleTests()
60 new BigDecimal("78403046.66936930160"), in simpleTests()
61 new BigDecimal("8091404.666936930160"), in simpleTests()
[all …]
DDivideTests.java23 package test.java.math.BigDecimal;
33 import static java.math.BigDecimal.*;
43 BigDecimal anotherDivide(BigDecimal dividend, BigDecimal divisor) { in anotherDivide()
53 return BigDecimal.ZERO; in anotherDivide()
149 BigDecimal bd; in powersOf2and5()
152 bd = BigDecimal.ONE.divide(new BigDecimal(product=powerOf2*powerOf5)); in powersOf2and5()
154 Assert.fail((new BigDecimal(powerOf2)).toString() + " / " + in powersOf2and5()
155 … (new BigDecimal(powerOf5)).toString() + " threw an exception."); in powersOf2and5()
159 bd = new BigDecimal(powerOf2).divide(new BigDecimal(powerOf5)); in powersOf2and5()
161 Assert.fail((new BigDecimal(powerOf2)).toString() + " / " + in powersOf2and5()
[all …]
DIntegralDivisionTests.java23 package test.java.math.BigDecimal;
47 BigDecimal [][] moreTestCases = { in dividetoIntegralValueTests()
48 {new BigDecimal("11003"), new BigDecimal("10"), new BigDecimal("1100")}, in dividetoIntegralValueTests()
49 {new BigDecimal("11003"), new BigDecimal("1e1"), new BigDecimal("1100.0")}, in dividetoIntegralValueTests()
50 {new BigDecimal("1e9"), new BigDecimal("1"), new BigDecimal("1e9")}, in dividetoIntegralValueTests()
51 {new BigDecimal("1e9"), new BigDecimal("1.00"), new BigDecimal("1e9")}, in dividetoIntegralValueTests()
52 {new BigDecimal("1e9"), new BigDecimal("0.1"), new BigDecimal("1e10")}, in dividetoIntegralValueTests()
53 {new BigDecimal("10e8"), new BigDecimal("0.1"), new BigDecimal("10e9")}, in dividetoIntegralValueTests()
54 {new BigDecimal("400e1"), new BigDecimal("5"), new BigDecimal("80e1")}, in dividetoIntegralValueTests()
55 {new BigDecimal("400e1"), new BigDecimal("4.999999999"), new BigDecimal("8e2")}, in dividetoIntegralValueTests()
[all …]
DRangeTests.java23 package test.java.math.BigDecimal;
34 import java.math.BigDecimal;
44 private static void addTest(BigDecimal arg1, BigDecimal arg2, BigDecimal expectedResult) { in addTest()
45 BigDecimal result = arg1.add(arg2); in addTest()
70 new BigDecimal("85070591730234615847396907784232501249"), in addBoundaryTest()
71 BigDecimal.valueOf(0), in addBoundaryTest()
72 new BigDecimal("85070591730234615847396907784232501249") ); in addBoundaryTest()
74 new BigDecimal("-85070591730234615847396907784232501249"), in addBoundaryTest()
75 BigDecimal.valueOf(0), in addBoundaryTest()
76 new BigDecimal("-85070591730234615847396907784232501249") ); in addBoundaryTest()
[all …]
DIntegralValueTests.java29 package test.java.math.BigDecimal;
31 import java.math.BigDecimal;
45 private static final Map<BigDecimal, Number> INT_VALUES =
49 Map.entry(new BigDecimal("2147483647"), Integer.MAX_VALUE),
50 Map.entry(new BigDecimal("2147483647.0"), Integer.MAX_VALUE),
51 Map.entry(new BigDecimal("2147483647.00"), Integer.MAX_VALUE),
53 Map.entry(new BigDecimal("-2147483647"), -Integer.MAX_VALUE),
54 Map.entry(new BigDecimal("-2147483647.0"), -Integer.MAX_VALUE),
57 Map.entry(new BigDecimal("-2147483648"), Integer.MIN_VALUE),
58 Map.entry(new BigDecimal("-2147483648.1"), Integer.MIN_VALUE),
[all …]
DPowTests.java23 package test.java.math.BigDecimal;
41 BigDecimal[][] testCases = { in zeroAndOneTests()
42 …{BigDecimal.valueOf(0, Integer.MAX_VALUE), new BigDecimal(0), BigDecimal.valueOf(1, … in zeroAndOneTests()
43 …{BigDecimal.valueOf(0, Integer.MAX_VALUE), new BigDecimal(1), BigDecimal.valueOf(0, … in zeroAndOneTests()
44 …{BigDecimal.valueOf(0, Integer.MAX_VALUE), new BigDecimal(2), BigDecimal.valueOf(0, … in zeroAndOneTests()
45 …{BigDecimal.valueOf(0, Integer.MAX_VALUE), new BigDecimal(999999999), BigDecimal.valueOf(0, … in zeroAndOneTests()
47 …{BigDecimal.valueOf(0, Integer.MIN_VALUE), new BigDecimal(0), BigDecimal.valueOf(1, … in zeroAndOneTests()
48 …{BigDecimal.valueOf(0, Integer.MIN_VALUE), new BigDecimal(1), BigDecimal.valueOf(0, … in zeroAndOneTests()
49 …{BigDecimal.valueOf(0, Integer.MIN_VALUE), new BigDecimal(2), BigDecimal.valueOf(0, … in zeroAndOneTests()
50 …{BigDecimal.valueOf(0, Integer.MIN_VALUE), new BigDecimal(999999999), BigDecimal.valueOf(0, … in zeroAndOneTests()
[all …]
DMultiplyTests.java23 package test.java.math.BigDecimal;
33 import static java.math.BigDecimal.*;
43 BigDecimal[] bd1 = { in multiplyTests()
44 new BigDecimal("123456789"), in multiplyTests()
45 new BigDecimal("1234567898"), in multiplyTests()
46 new BigDecimal("12345678987") in multiplyTests()
49 BigDecimal[] bd2 = { in multiplyTests()
50 new BigDecimal("987654321"), in multiplyTests()
51 new BigDecimal("8987654321"), in multiplyTests()
52 new BigDecimal("78987654321") in multiplyTests()
[all …]
DIntValueExactTests.java29 package test.java.math.BigDecimal;
49 private static int simpleIntValueExact(BigDecimal bd) { in simpleIntValueExact()
58 Map<BigDecimal, Integer> successCases = in intValueExactSuccessful()
59 Map.ofEntries(entry(new BigDecimal("2147483647"), Integer.MAX_VALUE), // 2^31 -1 in intValueExactSuccessful()
60 entry(new BigDecimal("2147483647.0"), Integer.MAX_VALUE), in intValueExactSuccessful()
61 entry(new BigDecimal("2147483647.00"), Integer.MAX_VALUE), in intValueExactSuccessful()
63 entry(new BigDecimal("-2147483648"), Integer.MIN_VALUE), // -2^31 in intValueExactSuccessful()
64 entry(new BigDecimal("-2147483648.0"), Integer.MIN_VALUE), in intValueExactSuccessful()
65 entry(new BigDecimal("-2147483648.00"),Integer.MIN_VALUE), in intValueExactSuccessful()
67 entry(new BigDecimal("1e0"), 1), in intValueExactSuccessful()
[all …]
DSquareRootTests.java23 package test.java.math.BigDecimal;
37 import static java.math.BigDecimal.ONE;
38 import static java.math.BigDecimal.TEN;
39 import static java.math.BigDecimal.ZERO;
40 import static java.math.BigDecimal.valueOf;
44 private static BigDecimal TWO = new BigDecimal(2);
49 private static final BigDecimal ONE_TENTH = valueOf(1L, 1);
56 BigDecimal input = BigDecimal.valueOf(i, j); in negativeTests()
57 BigDecimal result = input.sqrt(MathContext.DECIMAL64); in negativeTests()
70 BigDecimal expected = BigDecimal.valueOf(0L, i/2); in zeroTests()
[all …]
DNegateTests.java23 package test.java.math.BigDecimal;
40 static BigDecimal negateThenRound(BigDecimal bd, MathContext mc) { in negateThenRound()
45 static BigDecimal absThenRound(BigDecimal bd, MathContext mc) { in absThenRound()
50 static void negateTest(BigDecimal[][] testCases, MathContext mc) { in negateTest()
51 for (BigDecimal [] testCase : testCases) { in negateTest()
53 BigDecimal bd = testCase[0]; in negateTest()
54 BigDecimal neg1 = bd.negate(mc); in negateTest()
55 BigDecimal neg2 = negateThenRound(bd, mc); in negateTest()
56 BigDecimal expected = testCase[1]; in negateTest()
65 BigDecimal abs = bd.abs(mc); in negateTest()
[all …]
DFloatDoubleValueTests.java23 package test.java.math.BigDecimal;
49 static void testDoubleValue0(long i, BigDecimal bd) { in testDoubleValue0()
54 static void testFloatValue0(long i, BigDecimal bd) { in testFloatValue0()
59 static void checkFloat(BigDecimal bd, float f) { in checkFloat()
66 static void checkDouble(BigDecimal bd, double d) { in checkDouble()
94 BigDecimal bd1 = new BigDecimal(i); in testFloatDoubleValue()
95 BigDecimal bd2 = new BigDecimal(-i); in testFloatDoubleValue()
123 BigDecimal bd1 = new BigDecimal(i); in testDoubleValue()
124 BigDecimal bd2 = new BigDecimal(-i); in testDoubleValue()
135 BigDecimal bd1 = new BigDecimal(i); in testDoubleValue()
[all …]
DZeroScalingTests.java23 package test.java.math.BigDecimal;
45 static BigDecimal[] zeros = new BigDecimal[23];
48 zeros[i] = new BigDecimal(BigInteger.ZERO, i-10);
50 zeros[21] = new BigDecimal(BigInteger.ZERO, Integer.MIN_VALUE);
51 zeros[22] = new BigDecimal(BigInteger.ZERO, Integer.MAX_VALUE);
54 static BigDecimal element = BigDecimal.valueOf(100, -2);
69 for(BigDecimal zero1: zeros) { in addTests()
70 for(BigDecimal zero2: zeros) { in addTests()
71 BigDecimal expected = new BigDecimal(BigInteger.ZERO, in addTests()
73 BigDecimal result = zero1.add(zero2); in addTests()
[all …]
DEqualsTests.java23 package test.java.math.BigDecimal;
32 import static java.math.BigDecimal.*;
42 BigDecimal[][] testValues = { in testEquals()
54 {new BigDecimal("123456789123456789123"), in testEquals()
55 new BigDecimal(new BigInteger("123456789123456789123"))}, in testEquals()
56 {new BigDecimal("123456789123456789123"), in testEquals()
57 new BigDecimal(new BigInteger("123456789123456789124"))}, in testEquals()
59 {valueOf(Long.MIN_VALUE), new BigDecimal("-9223372036854775808")}, in testEquals()
60 {new BigDecimal("9223372036854775808"), valueOf(Long.MAX_VALUE)}, in testEquals()
62 {valueOf(Math.round(Math.pow(2, 10))), new BigDecimal("1024")}, in testEquals()
[all …]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/math/
DBigDecimalTest.java24 import java.math.BigDecimal;
39 BigDecimal big = new BigDecimal(value); in test_ConstructorLjava_math_BigInteger()
49 BigDecimal big = new BigDecimal(value2, 5); in test_ConstructorLjava_math_BigIntegerI()
61 BigDecimal big = new BigDecimal(123E04); in test_ConstructorD()
65 big = new BigDecimal(1.2345E-12); in test_ConstructorD()
68 big = new BigDecimal(-12345E-3); in test_ConstructorD()
71 big = new BigDecimal(5.1234567897654321e138); in test_ConstructorD()
75 big = new BigDecimal(0.1); in test_ConstructorD()
79 big = new BigDecimal(0.00345); in test_ConstructorD()
84 big = new BigDecimal(-0.0); in test_ConstructorD()
[all …]
DBigDecimalCompareTest.java23 import java.math.BigDecimal;
41 BigDecimal aNumber = new BigDecimal(a); in testAbsNeg()
51 BigDecimal aNumber = new BigDecimal(a); in testAbsPos()
61 BigDecimal aNumber = new BigDecimal(a); in testAbsMathContextNeg()
67 BigDecimal res = aNumber.abs(mc); in testAbsMathContextNeg()
77 BigDecimal aNumber = new BigDecimal(a); in testAbsMathContextPos()
83 BigDecimal res = aNumber.abs(mc); in testAbsMathContextPos()
96 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testCompareEqualScale1()
97 BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); in testCompareEqualScale1()
110 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testCompareEqualScale2()
[all …]
DBigDecimalArithmeticTest.java20 import java.math.BigDecimal;
42 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testAddEqualScalePosPos()
43 BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); in testAddEqualScalePosPos()
44 BigDecimal result = aNumber.add(bNumber); in testAddEqualScalePosPos()
59 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testAddMathContextEqualScalePosPos()
60 BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); in testAddMathContextEqualScalePosPos()
62 BigDecimal result = aNumber.add(bNumber, mc); in testAddMathContextEqualScalePosPos()
77 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testAddEqualScaleNegNeg()
78 BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); in testAddEqualScaleNegNeg()
79 BigDecimal result = aNumber.add(bNumber); in testAddEqualScaleNegNeg()
[all …]
DBigDecimalConvertTest.java24 import java.math.BigDecimal;
38 BigDecimal aNumber = new BigDecimal(a); in testDoubleValueNeg()
48 BigDecimal aNumber = new BigDecimal(a); in testDoubleValuePos()
58 BigDecimal aNumber = new BigDecimal(a); in testDoubleValuePosInfinity()
68 BigDecimal aNumber = new BigDecimal(a); in testDoubleValueNegInfinity()
78 BigDecimal aNumber = new BigDecimal(a); in testDoubleValueMinusZero()
89 BigDecimal aNumber = new BigDecimal(a); in testDoubleValuePlusZero()
100 BigDecimal aNumber = new BigDecimal(a); in testFloatValueNeg()
110 BigDecimal aNumber = new BigDecimal(a); in testFloatValuePos()
120 BigDecimal aNumber = new BigDecimal(a); in testFloatValuePosInfinity()
[all …]
DBigDecimalScaleOperationsTest.java37 BigDecimal aNumber = new BigDecimal(new BigInteger(a)); in testScaleDefault()
48 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testScaleNeg()
59 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testScalePos()
70 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testScaleZero()
81 BigDecimal aNumber = new BigDecimal(bNumber, aScale); in testUnscaledValue()
92 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testSetScaleGreater()
93 BigDecimal bNumber = aNumber.setScale(newScale); in testSetScaleGreater()
104 BigDecimal aNumber = new BigDecimal(a); in testSetScaleLess()
105 BigDecimal bNumber = aNumber.setScale(newScale); in testSetScaleLess()
117 BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); in testSetScaleException()
[all …]
DBigDecimalConstructorsTest.java23 import java.math.BigDecimal;
41 assertEquals("incorrect string value", oneS, BigDecimal.ONE.toString()); in testFieldONE()
42 assertEquals("incorrect double value", oneD, BigDecimal.ONE.doubleValue(), 0); in testFieldONE()
51 assertEquals("incorrect string value", oneS, BigDecimal.TEN.toString()); in testFieldTEN()
52 assertEquals("incorrect double value", oneD, BigDecimal.TEN.doubleValue(), 0); in testFieldTEN()
61 assertEquals("incorrect string value", oneS, BigDecimal.ZERO.toString()); in testFieldZERO()
62 assertEquals("incorrect double value", oneD, BigDecimal.ZERO.doubleValue(), 0); in testFieldZERO()
71 BigDecimal aNumber = new BigDecimal(bA); in testConstrBI()
76 new BigDecimal((BigInteger) null); in testConstrBI()
90 BigDecimal aNumber = new BigDecimal(bA, aScale); in testConstrBIScale()
[all …]
/libcore/luni/src/test/java/libcore/java/math/
DOldBigDecimalConvertTest.java24 import java.math.BigDecimal;
33 BigDecimal aNumber = new BigDecimal(a); in test_IntValueExactNeg()
44 BigDecimal aNumber = new BigDecimal(a); in test_IntValueExactPos()
54 BigDecimal aNumber = new BigDecimal("-2147483647.999"); in test_IntValueExactFloatNeg()
65 BigDecimal aNumber = new BigDecimal(a); in test_IntValueExactFloatPos()
76 BigDecimal aNumber = new BigDecimal(a); in test_IntValueExactLongPos()
83 BigDecimal aNumber = new BigDecimal(a); in test_IntValueExactLongNeg()
90 BigDecimal aNumber = new BigDecimal(a); in test_LongValueExactNeg()
101 BigDecimal aNumber = new BigDecimal(a); in test_LongValueExactPos()
111 BigDecimal aNumber = new BigDecimal("-9223372036854775807.99999"); in test_LongValueExactFloatNeg()
[all …]
DOldBigDecimalArithmeticTest.java20 import java.math.BigDecimal;
30 BigDecimal a, b, res; in testAddMathContextNonTrivial()
33 a = new BigDecimal("123456789012345.678"); in testAddMathContextNonTrivial()
34 b = new BigDecimal("100000000000000.009"); in testAddMathContextNonTrivial()
45 a = new BigDecimal("1234567890123456789012345678.9012395"); in testAddMathContextNonTrivial()
46 b = new BigDecimal("1000000000000000090000000000.0000005"); in testAddMathContextNonTrivial()
55 BigDecimal a, b, res; in testSubtractMathContextNonTrivial()
58 a = new BigDecimal("12345678901234567.8"); in testSubtractMathContextNonTrivial()
59 b = new BigDecimal("10000000000000000.9"); in testSubtractMathContextNonTrivial()
68 a = new BigDecimal("1234567890123456789012345678.9012395"); in testSubtractMathContextNonTrivial()
[all …]
DOldBigDecimalConstructorsTest.java23 import java.math.BigDecimal;
42 BigDecimal result = new BigDecimal(bA, mc); in testConstrBigIntegerMathContext()
48 BigDecimal bd; in testConstrBigIntegerMathContext()
53 bd = new BigDecimal(bi, mc); in testConstrBigIntegerMathContext()
55 bd = new BigDecimal(nbi, mc); in testConstrBigIntegerMathContext()
59 bd = new BigDecimal(bi, mc); in testConstrBigIntegerMathContext()
61 bd = new BigDecimal(nbi, mc); in testConstrBigIntegerMathContext()
65 bd = new BigDecimal(bi, mc); in testConstrBigIntegerMathContext()
67 bd = new BigDecimal(nbi, mc); in testConstrBigIntegerMathContext()
71 bd = new BigDecimal(bi, mc); in testConstrBigIntegerMathContext()
[all …]
DBigDecimalTest.java19 import java.math.BigDecimal;
27 import static java.math.BigDecimal.valueOf;
58 BigDecimal parsed = new BigDecimal(value); in assertPrecision()
62 BigDecimal computed = parsed.divide(BigDecimal.ONE); in assertPrecision()
68 BigDecimal bigDecimal = new BigDecimal("0.999999999999999"); in testRound()
69 BigDecimal rounded = bigDecimal.round(new MathContext(2, RoundingMode.FLOOR)); in testRound()
75 BigDecimal a = new BigDecimal("-0.011111111111111111111"); in testPrecisionFromString()
76 BigDecimal b = a.multiply(BigDecimal.ONE); in testPrecisionFromString()
98 assertEquals(new BigDecimal(BigInteger.valueOf(-10), 1), new BigDecimal("-1.0")); in testPrecisionFromString_simplePowersOfTen()
99 assertEquals(new BigDecimal(BigInteger.valueOf(-1), 1), new BigDecimal("-0.1")); in testPrecisionFromString_simplePowersOfTen()
[all …]
/libcore/ojluni/src/main/java/java/math/
DRoundingMode.java134 UP(BigDecimal.ROUND_UP),
164 DOWN(BigDecimal.ROUND_DOWN),
195 CEILING(BigDecimal.ROUND_CEILING),
226 FLOOR(BigDecimal.ROUND_FLOOR),
259 HALF_UP(BigDecimal.ROUND_HALF_UP),
289 HALF_DOWN(BigDecimal.ROUND_HALF_DOWN),
328 HALF_EVEN(BigDecimal.ROUND_HALF_EVEN),
356 UNNECESSARY(BigDecimal.ROUND_UNNECESSARY);
381 case BigDecimal.ROUND_UP -> UP; in valueOf()
382 case BigDecimal.ROUND_DOWN -> DOWN; in valueOf()
[all …]

1234