I found some code in legacy software and i was interested in knowing which provides better precision, as it currently is where it takes the double and calculates on them:
double doubleNum = (Math.round(55.88d * 100) - Math.round(2.33d * 100));
second option
BigDecimal bnv = BigDecimal.valueOf(55.88);
BigDecimal bsv = BigDecimal.valueOf(2.33);
System.out.println(bnv.subtract(bsv).setScale(2));
Both produce the same output, my understanding was that using bigdecimal ensures that is more precise. But there could be loss when converting double to BigDecimal
Also the first option there is possible loss when casting..
I always use BigDecimal, but in this case.