Can anyone recommend an efficient way of determining whether a BigDecimal
is an integer value in the mathematical sense?
At present I have
One possiblity should be to check if scale() is zero or negative. In that case the BigDecimal should have no digits after the decimal point and the number should be a mathematical integer if I understand your question correctly.
Update: If positive, it could still be an integer, but you cannot spare extra object creations for further in-depth checks in that case. An example for such a case is given at the stripTrailingZeros() method javadoc (thanks Joachim for the hint in his answer).