Seems like the subtraction is triggering some kind of issue and the resulting value is wrong.
double tempCommission = targetPremium.doubleValue()*rate.doubleValue()/100d;
double netToCompany = targetPremium.doubleValue() - tempCommission;
double dCommission = request.getPremium().doubleValue() - netToCompany;
Given your example, the last line would be as following using BigDecimal.
import java.math.BigDecimal; BigDecimal premium = BigDecimal.valueOf(1586.6d); BigDecimal netToCompany = BigDecimal.valueOf(708.75d); BigDecimal commission = premium.subtract(netToCompany); System.out.println(commission + " = " + premium + " - " + netToCompany);
This results in the following output.
877.85 = 1586.6 - 708.75