You can use setScale() e.g.
double d = ...
BigDecimal db = new BigDecimal(d).setScale(12, BigDecimal.ROUND_HALF_UP);
More Related Contents:
- Double vs. BigDecimal?
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- Representing Monetary Values in Java [closed]
- Using BigDecimal to work with currencies
- Logarithm of a BigDecimal
- How to print formatted BigDecimal values?
- Safe String to BigDecimal conversion
- Addition for BigDecimal
- Square root of BigDecimal in Java
- BigDecimal equals() versus compareTo()
- Rounding BigDecimal to *always* have two decimal places
- Convert double to BigDecimal and set BigDecimal Precision
- Java BigDecimal: Round to the nearest whole value
- BigDecimal setScale and round
- BigDecimal, precision and scale
- Format a BigDecimal as String with max 2 decimal digits, removing 0 on decimal part
- What to do with Java BigDecimal performance?
- Java BigDecimal precision problems
- ArithmeticException thrown during BigDecimal.divide
- BigDecimal adding wrong value
- How can I parse a String to BigDecimal? [duplicate]
- Change DecimalFormat locale
- Java BigDecimal memory usage?
- round BigDecimal to nearest 5 cents
- BigDecimal summary statistics
- BigDecimal from Double incorrect value?
- How to use comparison operators like >, =, < on BigDecimal
- How to display a number with always 2 decimal points using BigDecimal?
- How do I map a BigDecimal in Hibernate so I get back the same scale I put in?
- Why is BigDecimal.equals specified to compare both value and scale individually?