Code examples for BigDecimal

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
33:	BigDecimal expected = new BigDecimal("123456789123456789.987654321"); 
-
36:	ByteBuffer buffer = decimal.serialize(expected); 
-
38:	Assert.assertEquals(expected, actual); 
Full Snippet Info
8
CodeRank
58:	decimal = new BigDecimal(source); 
-
65:	return decompose(decimal); 
Full Snippet Info
8
CodeRank
651:	BigDecimal bd = new BigDecimal(a); 
652:	fail("NumberFormatException has not been caught: " + bd.toString()); 
Full Snippet Info
8
CodeRank
68:	BigDecimal right = new BigDecimal(number); 
Full Snippet Info
7
CodeRank
88:	BigDecimal bd = normalize(new BigDecimal(bi), true); 
-
217:	if (d.compareTo(BigDecimal.ZERO) == 0) { 
-
221:	d = d.stripTrailingZeros(); 
222:	if (d.scale() < 0) { 
-
224:	d = d.setScale(0); 
-
237:	int intDigits = bd.precision() - bd.scale(); 
-
243:	int maxScale = Math.min(MAX_SCALE, Math.min(MAX_PRECISION - intDigits, bd.scale())); 
244:	if (bd.scale() > maxScale ) { 
-
246:	bd = bd.setScale(maxScale, RoundingMode.HALF_UP); 
Full Snippet Info
7
CodeRank
74:	BigDecimal i = new BigDecimal("100.5"); 
-
77:	user.setMoney(i); 
-
79:	i = i.subtract(BigDecimal.valueOf(50)); 
-
81:	i = i.add(BigDecimal.valueOf(25)); 
-
88:	assertEquals(user.getMoney(), i); 
Full Snippet Info
7
CodeRank
39:	if (!value.equals(monetaryAmount.value)) return false; 
Full Snippet Info
7
CodeRank
76:	return ((BigDecimal) l).divide(new BigDecimal(r.intValue()), RoundingMode.HALF_UP); 
Full Snippet Info
7
CodeRank
179:	value = value.multiply(_factor); 
-
181:	int scale = _scale == null ? value.scale() : _scale.intValue(); 
182:	value = value.divide(_factor, scale, BigDecimal.ROUND_HALF_EVEN); 
-
254:	if(newValue.scale() == 0) { 
255:	newValue = newValue.setScale(4); 
Full Snippet Info
7
CodeRank
36:	BigDecimal v = new BigDecimal ( "-1" ); 
-
80:	is1_7OorLater = version.compareTo ( new BigDecimal ( "1.7" )) >=0; 
81:	is1_7 = version.compareTo ( new BigDecimal ( "1.7" ))==0; 
82:	is1_8 = version.compareTo ( new BigDecimal ( "1.8" ))==0; 
Full Snippet Info
7
CodeRank
36:	account.profit(new BigDecimal(1000), DateTime.now().plusMillis(1)); 
Full Snippet Info
7
CodeRank
76:	return ((BigDecimal) l).multiply(new BigDecimal(r.intValue())); 
Full Snippet Info
7
CodeRank
69:	BigDecimal bdOne = new BigDecimal("1"); 
-
72:	assertTrue(comparator.compare(bdOne, bdTwo) < 0); 
73:	assertTrue(comparator.compare(bdOne, new BigDecimal("1")) == 0); 
74:	assertTrue(comparator.compare(bdTwo, bdOne) > 0); 
-
77:	assertTrue(comparator.compare(1, bdOne) == 0); 
78:	assertTrue(comparator.compare(2, bdOne) > 0); 
-
81:	assertTrue(comparator.compare(1.0d, bdOne) == 0); 
82:	assertTrue(comparator.compare(2.0d, bdOne) > 0); 
-
85:	assertTrue(comparator.compare(1.0f, bdOne) == 0); 
86:	assertTrue(comparator.compare(2.0f, bdOne) > 0); 
-
89:	assertTrue(comparator.compare(1L, bdOne) == 0); 
90:	assertTrue(comparator.compare(2L, bdOne) > 0); 
Full Snippet Info
7
CodeRank
103:	return numerator.divide(denominator); 
-
105:	return numerator.divide(denominator, BigDecimal.ROUND_HALF_UP); 
Full Snippet Info
7
CodeRank
73:	return ((BigDecimal) l).remainder(new BigDecimal(r.longValue())); 
Full Snippet Info
7
CodeRank
109:	multipleShareTrade.setConditions(new Conditions(new BigDecimal(10), new BigDecimal(0.01))); 
Full Snippet Info
7
CodeRank
39:	currentAmount = currentAmount.add(amount); 
Full Snippet Info
7
CodeRank
65:	} 
-
73:	"true".equals(LibFormulaBoot.getInstance().getGlobalConfig().getConfigProperty 
-
75:	return getExcelDate(date, excelBugCompatible, computeZeroDate(dateSystem, excelBugCompatible)); 
-
80:	final int zeroDate) 
-
176:	final BigDecimal fractionNum = date.subtract(wholeDays); 
177:	final BigDecimal fraction = fractionNum.multiply(DAY_MILLISECONDS); 
Full Snippet Info
7
CodeRank
65:	return n.setScale(0); 
-
73:	if(n.signum()<0) 
-
80:	n = n.add(DELTA); 
81:	round = n.setScale(1, BigDecimal.ROUND_DOWN); 
82:	return round.setScale(0, BigDecimal.ROUND_DOWN); 
Full Snippet Info
7
CodeRank
62:	return bigLeft.divide(bigRight); 
-
65:	int precision = Math.max(bigLeft.precision(), bigRight.precision()) + DIVISION_EXTRA_PRECISION; 
66:	BigDecimal result = bigLeft.divide(bigRight, new MathContext(precision)); 
67:	int scale = Math.max(Math.max(bigLeft.scale(), bigRight.scale()), DIVISION_MIN_SCALE); 
68:	if (result.scale() > scale) result = result.setScale(scale, BigDecimal.ROUND_HALF_UP); 
Full Snippet Info
7
CodeRank