I have encountered a rather unusual scenario in my coding. I have developed this app and it has been utilised for the past 6 months with no errors.
To simplify my problem.. I am using a decimalFormat to round up numbers and ensure that they are to 2 decimal places and this has been working perfectly.
However, a problem came up that was sent back to me and it was said that every other case works except for this specific one and it seems to be in particular just the number 4?
Case:
Total = 44.75 Mean = 4.475 MBW (2 decimal places) = 4.47 NOT 4.48
This led me to wonder is DecimalFormat always correct when rounding? the weird thing is this works when it is 1.475 it rounds to .48 and every number except for 4??
Anyone any ideas?
Java example:
final DecimalFormat df = new DecimalFormat("#0.00");
weight2 = 4.475
MBW = df.format(weight2);
The result above is still getting 4.47.. any normal rounding should be 4.48? This is working for any other whole number such as 1.475 is 1.48, 2.275 is 2.48... why is the whole number 4 not working???