Home
last modified time | relevance | path

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

12

/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 …]
DRoundingModeTest.java20 import java.math.BigDecimal;
29 …assertEquals("valueOf failed for ROUND_CEILING", RoundingMode.valueOf(BigDecimal.ROUND_CEILING), R… in test_valueOfI()
30 …assertEquals("valueOf failed for ROUND_DOWN", RoundingMode.valueOf(BigDecimal.ROUND_DOWN), Roundin… in test_valueOfI()
31 …assertEquals("valueOf failed for ROUND_FLOOR", RoundingMode.valueOf(BigDecimal.ROUND_FLOOR), Round… in test_valueOfI()
32 …assertEquals("valueOf failed for ROUND_HALF_DOWN", RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN… in test_valueOfI()
33 …assertEquals("valueOf failed for ROUND_HALF_EVEN", RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN… in test_valueOfI()
34 …assertEquals("valueOf failed for ROUND_HALF_UP", RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP), R… in test_valueOfI()
35 …assertEquals("valueOf failed for ROUND_UNNECESSARY", RoundingMode.valueOf(BigDecimal.ROUND_UNNECES… in test_valueOfI()
36 …assertEquals("valueOf failed for ROUND_UP", RoundingMode.valueOf(BigDecimal.ROUND_UP), RoundingMod… in test_valueOfI()
DMathContextTest.java20 import java.math.BigDecimal;
31 BigDecimal aNumber = new BigDecimal(a); in test_MathContextConstruction()
73 BigDecimal res = aNumber.abs(mcInt6); in test_MathContextConstruction()
75 new BigDecimal("1.23809E+68"), in test_MathContextConstruction()
/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 …]
DOldBigDecimalTest.java20 import java.math.BigDecimal;
34 BigDecimal big = new BigDecimal(123E04); in test_ConstructorD()
38 big = new BigDecimal(123.375); in test_ConstructorD()
41 big = new BigDecimal(Math.pow(2, -33)); in test_ConstructorD()
44 big = new BigDecimal(123456 * Math.pow(2, -33)); in test_ConstructorD()
47 big = new BigDecimal(-123456 * Math.pow(2, -33)); in test_ConstructorD()
62 BigDecimal bd; in test_constructor_String_plus_exp()
63 bd = new BigDecimal("+23e-0"); in test_constructor_String_plus_exp()
65 bd = new BigDecimal("-23e+0"); in test_constructor_String_plus_exp()
73 BigDecimal setScale1 = new BigDecimal(2.323E102); in test_setScaleILjava_math_RoundingMode()
[all …]
DOldBigDecimalScaleOperationsTest.java24 import java.math.BigDecimal;
30 BigDecimal a = new BigDecimal("12345.6789012345678901234567890123456789"); in testMovePointRightEx()
31 BigDecimal res = a.movePointRight(10); in testMovePointRightEx()
46 BigDecimal a = new BigDecimal("123456789012345678901234567890123456789E25"); in testMovePointRightEx2()
55 BigDecimal a = new BigDecimal("12345.6789012345678901234567890123456789"); in testScaleByPowerOfTenEx()
56 BigDecimal res = a.movePointRight(10); in testScaleByPowerOfTenEx()
70 a = new BigDecimal("123456789012345678901234567890123456789E25"); in testScaleByPowerOfTenEx()
83 BigDecimal x1 = new BigDecimal(1.23400); in testSetScale()
84 BigDecimal x2 = x1.setScale(75); in testSetScale()
DOldBigDecimalCompareTest.java24 import java.math.BigDecimal;
34 BigDecimal aNumber = new BigDecimal(a); in testAbsMathContextNeg()
58 BigDecimal aNumber = new BigDecimal(new BigInteger(a), 41); in testNegateMathContextPositive()
59 BigDecimal res = aNumber.negate(mc); in testNegateMathContextPositive()
/libcore/luni/src/main/java/java/math/
DRoundingMode.java32 UP(BigDecimal.ROUND_UP),
39 DOWN(BigDecimal.ROUND_DOWN),
48 CEILING(BigDecimal.ROUND_CEILING),
57 FLOOR(BigDecimal.ROUND_FLOOR),
63 HALF_UP(BigDecimal.ROUND_HALF_UP),
69 HALF_DOWN(BigDecimal.ROUND_HALF_DOWN),
75 HALF_EVEN(BigDecimal.ROUND_HALF_EVEN),
82 UNNECESSARY(BigDecimal.ROUND_UNNECESSARY);
102 case BigDecimal.ROUND_CEILING: in valueOf()
104 case BigDecimal.ROUND_DOWN: in valueOf()
[all …]
DBigDecimal.java35 public class BigDecimal extends Number implements Comparable<BigDecimal>, Serializable { class
166 private static final BigDecimal[] BI_SCALED_BY_ZERO = new BigDecimal[BI_SCALED_BY_ZERO_LENGTH];
172 private static final BigDecimal[] ZERO_SCALED_BY = new BigDecimal[11];
181 BI_SCALED_BY_ZERO[i] = new BigDecimal(i, 0);
182 ZERO_SCALED_BY[i] = new BigDecimal(0, i);
199 public static final BigDecimal ZERO = new BigDecimal(0, 0);
204 public static final BigDecimal ONE = new BigDecimal(1, 0);
209 public static final BigDecimal TEN = new BigDecimal(10, 0);
237 private BigDecimal(long smallValue, int scale){ in BigDecimal() method in BigDecimal
243 private BigDecimal(int smallValue, int scale){ in BigDecimal() method in BigDecimal
[all …]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/
DFormatterTest.java30 import java.math.BigDecimal;
3612 { BigDecimal.ZERO, "%e", "0.000000e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3613 { BigDecimal.ZERO, "%#.0e", "0.e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3614 { BigDecimal.ZERO, "%# 9.8e", " 0.00000000e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3615 { BigDecimal.ZERO, "%#+0(8.4e", "+0.0000e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3616 { BigDecimal.ZERO, "%-+17.6e", "+0.000000e+00 " }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3617 { BigDecimal.ZERO, "% 0(20e", " 00000000.000000e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3619 { BigDecimal.ONE, "%e", "1.000000e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3620 { BigDecimal.ONE, "%#.0e", "1.e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
3621 { BigDecimal.ONE, "%# 9.8e", " 1.00000000e+00" }, in test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalConversionE()
[all …]
/libcore/luni/src/test/java/libcore/java/text/
DDecimalFormatTest.java19 import java.math.BigDecimal;
66 assertEquals("17%", pf.format(BigDecimal.valueOf(0.17))); in testBigDecimalBug1897917()
70 BigDecimal bd = new BigDecimal(longDec); in testBigDecimalBug1897917()
126 assertEquals(df.format(BigDecimal.valueOf(0.16)), in testBigDecimalICUConsistency()
127 df.format(BigDecimal.valueOf(0.16).doubleValue())); in testBigDecimalICUConsistency()
128 assertEquals(df.format(BigDecimal.valueOf(0.0293)), in testBigDecimalICUConsistency()
129 df.format(BigDecimal.valueOf(0.0293).doubleValue())); in testBigDecimalICUConsistency()
130 assertEquals(df.format(BigDecimal.valueOf(0.006)), in testBigDecimalICUConsistency()
131 df.format(BigDecimal.valueOf(0.006).doubleValue())); in testBigDecimalICUConsistency()
132 assertEquals(df.format(BigDecimal.valueOf(0.00283)), in testBigDecimalICUConsistency()
[all …]
/libcore/benchmarks/src/benchmarks/regression/
DDecimalFormatBenchmark.java3 import java.math.BigDecimal;
21 private static final BigDecimal BD10E3 = new BigDecimal("10E3");
22 private static final BigDecimal BD10E9 = new BigDecimal("10E9");
23 private static final BigDecimal BD10E100 = new BigDecimal("10E100");
24 private static final BigDecimal BD10E1000 = new BigDecimal("10E1000");
/libcore/luni/src/test/java/libcore/java/util/
DFormatterTest.java19 import java.math.BigDecimal;
123 BigDecimal[] input = new BigDecimal[] { in test_BigDecimalFormatting()
124 new BigDecimal("20.00000"), in test_BigDecimalFormatting()
125 new BigDecimal("20.000000"), in test_BigDecimalFormatting()
126 new BigDecimal(".2"), in test_BigDecimalFormatting()
127 new BigDecimal("2"), in test_BigDecimalFormatting()
128 new BigDecimal("-2"), in test_BigDecimalFormatting()
129 new BigDecimal("200000000000000000000000"), in test_BigDecimalFormatting()
130 new BigDecimal("20000000000000000000000000000000000000000000000000") in test_BigDecimalFormatting()
/libcore/luni/src/main/java/javax/xml/datatype/
DDatatypeFactory.java22 import java.math.BigDecimal;
238 final BigDecimal seconds); in newDuration()
293BigDecimal realSeconds = (seconds != DatatypeConstants.FIELD_UNDEFINED) ? BigDecimal.valueOf((long… in newDuration()
422 BigInteger.valueOf(minutes), BigDecimal.valueOf(milliseconds, 3)); in newDurationDayTime()
426 BigDecimal seconds = BigDecimal.valueOf(milliseconds, 3); in newDurationDayTime()
480 (second != null)? new BigDecimal(second):null in newDurationDayTime()
795 final BigDecimal fractionalSecond, in newXMLGregorianCalendar()
839 BigDecimal realMillisecond = null; // undefined value in newXMLGregorianCalendar()
848 realMillisecond = BigDecimal.valueOf((long) millisecond, 3); in newXMLGregorianCalendar()
964 final BigDecimal fractionalSecond, in newXMLGregorianCalendarTime()
[all …]
DXMLGregorianCalendar.java22 import java.math.BigDecimal;
397 public abstract void setFractionalSecond(BigDecimal fractional); in setFractionalSecond()
420 BigDecimal fractional) { in setTime()
591 BigDecimal fractionalSeconds = getFractionalSecond(); in getMillisecond()
618 public abstract BigDecimal getFractionalSecond(); in getFractionalSecond()
DDuration.java22 import java.math.BigDecimal;
634 return multiply(BigDecimal.valueOf(factor)); in multiply()
684 public abstract Duration multiply(final BigDecimal factor); in multiply()
909 BigDecimal seconds = (BigDecimal) getField(DatatypeConstants.SECONDS); in toString()
936 private String toString(BigDecimal bd) { in toString()
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/
DDecimalFormatTest.java21 import java.math.BigDecimal;
69 assertEquals(new BigDecimal("123.123"), result); in test_parse_bigDecimal()
75 assertFalse(result instanceof BigDecimal); in test_parse_bigDecimal()
109 assertTrue(number instanceof BigDecimal); in test_parse_returnType()
110 assertEquals(new BigDecimal("23.1"), number); in test_parse_returnType()
165 assertTrue(number instanceof BigDecimal); in test_parse_returnType()
168 assertTrue(number instanceof BigDecimal); in test_parse_returnType()
172 assertTrue(number instanceof BigDecimal); in test_parse_returnType()
184 assertTrue(number instanceof BigDecimal); in test_parse_returnType()
185 assertEquals(new BigDecimal("23.1"), number); in test_parse_returnType()
[all …]

12