You are not performing the same operations.
When you are doing the double operations, the normal java order of operations is applying:
a-a/1.05
= a - (a/1.05)
But when you are running the methods on BigDecimal
, the operations are evaluated in the order you are calling them, so
b.subtract(b).divide(new BigDecimal(1.05))
is equivalent to
(b - b) / 1.05
= 0 / 1.05
= 0