2007-09-04

Java BigDecimal

Here is another reason why Java's BigDecimal is not very useful.  Try this:

BigDecimal.ONE.divide(new BigDecimal("3"))

You'll get this exception:

java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.

Java sorely needs a rational type.