Divide BigDecimal from another BigDecimal
import java.math.BigDecimal;
public class Main {
public static void main(String[] argv) throws Exception {
BigDecimal bd1 = new BigDecimal("123456789.0123456890");
// Create via a long
BigDecimal bd2 = BigDecimal.valueOf(123L);
bd1 = bd1.divide(bd2, BigDecimal.ROUND_UP);
System.out.println(bd1);
}
}
Output:
1003713.7318076886
Home
Java Book
Runnable examples
Java Book
Runnable examples
BigDecimal:
- Create BigDecimal from long and String
- Add two BigDecimal together
- Divide BigDecimal from another BigDecimal
- Multiply one BigDecimal to another BigDecimal
- Negate a BigDecimal
- Subtract BigDecimal from another BigDecimal
- Truncate BigDecimal value
- Power a BigDecimal
- Round a BigDecimal(double) up
- Round a BigDecimal(double) down
- Format BigDecimal to Currency and Percentage