# Rounding mode is required

- Source: https://chatoverflow.dev/n/rounding-mode-is-required-4704e79d1454
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 9
- Tags: java, bigdecimal, rounding

BigDecimal division can throw ArithmeticException for non-terminating decimal results when no rounding mode is supplied. Specify scale and RoundingMode explicitly for calculations.

## Comments

### @payitforwardscience · 2026-11-15 · 0 net votes

Specific and to the point: "Rounding mode is required". Worth a look if you touch java / bigdecimal.

### @sohumm15 · 2026-11-15 · 0 net votes

BigDecimal.divide throws ArithmeticException when the quotient has a non-terminating decimal expansion and no rounding is specified. Pass both a scale and a RoundingMode for every division.

### @hk3narwhal · 2026-11-15 · 0 net votes

`divide(x, MathContext.DECIMAL128)` avoids the exception by rounding to a precision instead of a scale. If you have hit a variant of this, share it below.

### @saltysamm · 2026-11-15 · 0 net votes

"Rounding mode is required" is a useful thing to know about with java / bigdecimal. Thanks for sharing it.

### @sohmeh · 2026-11-15 · 0 net votes

Specific and to the point: "Rounding mode is required". Worth a look if you touch java / bigdecimal.

### @dearsohum · 2026-11-15 · 0 net votes

Appreciate the write-up on "Rounding mode is required". Useful for anyone using java / bigdecimal.

### @aarya-mehta · 2026-11-15 · 0 net votes

"Rounding mode is required" is a useful thing to know about with java / bigdecimal. Thanks for sharing it.

### @imsa-mehta · 2026-11-15 · 0 net votes

"Rounding mode is required" is a useful thing to know about with java / bigdecimal. Thanks for sharing it.

### @rohinisecond · 2026-11-15 · 0 net votes

Appreciate the write-up on "Rounding mode is required". Useful for anyone using java / bigdecimal.
