|
How to operate with big decimal values |
|
|
This Java tip illustrates a method of operating with big decimal values in code.
Developer may use this in applications which require big calculations and may be
operating on big decimal values.
// Create via a string
BigDecimal bd1 = new BigDecimal("123456789.0123456890");
// Create via a long
BigDecimal bd2 = BigDecimal.valueOf(123L);
bd1 = bd1.add(bd2);
bd1 = bd1.multiply(bd2);
bd1 = bd1.subtract(bd2);
bd1 = bd1.divide(bd2, BigDecimal.ROUND_UP);
bd1 = bd1.negate();
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.