Create BigDecimal from long and String


import java.math.BigDecimal;

public class Main {
  public static void main(String[] argv) throws Exception {
    // Create via a string
    BigDecimal bd1 = new BigDecimal("123456789.0123456890");

    // Create via a long
    BigDecimal bd2 = BigDecimal.valueOf(123L);

    bd1 = bd1.add(bd2);
    System.out.println(bd1);
  }
}

Output:


123456912.0123456890
Home 
  Java Book 
    Runnable examples  

BigDecimal:
  1. Create BigDecimal from long and String
  2. Add two BigDecimal together
  3. Divide BigDecimal from another BigDecimal
  4. Multiply one BigDecimal to another BigDecimal
  5. Negate a BigDecimal
  6. Subtract BigDecimal from another BigDecimal
  7. Truncate BigDecimal value
  8. Power a BigDecimal
  9. Round a BigDecimal(double) up
  10. Round a BigDecimal(double) down
  11. Format BigDecimal to Currency and Percentage