<<< Copying BigDecimals | Index | Formatting Currency >>> |
Be careful using .equals() method to compare BigDecimals --
the .equals() compares both the values and the scale.
Instead, to compare unrounded valus of the two BigDecimals, use the .compareTo() and .signum() methods:
amountA.compareTo(amountB); // returns (-1 if A < B), (0 if A == B), (1 if A > B) amountA.signum(); // returns (-1 if A < 0), (0 if A == 0), (1 if A > 0)
<<< Copying BigDecimals | Index | Formatting Currency >>> |