You're seeing floating-point imprecision.
(720000 + 144000) * 0.285
actually computes to 246239.99999999997
.
Reading that as a double
will round up when printed, but casting to an integral type will always truncate.
Depending on your use case, you may want to use decimal
or a BigDecimal
implementation instead of double, or just round.