Closed PowerUser1234 closed 6 years ago
javaoo only provides operators syntactic sugar. what operators do is up to its implementation. I cannot affect BigDecimal#divide implementation.
As a workaround, you can create your wrapper classes and override divide
method to something like super.divide(x, precision, RoundingMode.HALF_UP)
.
Or you can use another bigmath library.
BigDecimal a = new BigDecimal(1, MathContext.DECIMAL64);
BigDecimal b = new BigDecimal(3, MathContext.DECIMAL64);
BigDecimal c2 = a/b;
out.println(c2);