Convert double and long to BigDecimal

static BigDecimal valueOf(double val)
Translates a double into a BigDecimal.
static BigDecimal valueOf(long val)
Translates a long value into a BigDecimal with a scale of zero.
static BigDecimal valueOf(long unscaledVal, int scale)
Translates a long unscaled value and an int scale into a BigDecimal.

import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        System.out.println(BigDecimal.valueOf(1.00001));
    }
}

The output:


1.00001
Home 
  Java Book 
    Essential Classes  

BigDecimal:
  1. BigDecimal class
  2. Constants for One, Ten and Zero
  3. Rounding mode
  4. Create BigDecimals
  5. Methods used to do calculation
  6. Convert BigDecimal to primitive data types
  7. Compare two BigDecimal
  8. Move decimal point
  9. Scale and precision
  10. Convert BigDecimal to String
  11. Remove the trailing zeros
  12. Convert double and long to BigDecimal
  13. Calculating Euler's number e with BigDecimal