Check if BigDecimal is integer value
- by Adamski
Can anyone recommend an efficient way of determining whether a BigDecimal is an integer value in the mathematical sense?
At present I have the following code:
private boolean isIntegerValue(BigDecimal bd) {
boolean ret;
try {
bd.toBigIntegerExact();
ret = true;
} catch (ArithmeticException ex) {
ret = false;
…