Variances in the "least significant digit" can cause the entire number to be rounded in the wrong direction.
Lets take an item that costs $0.705 - the half cent is from discount, or tax or something, or this is a 10% discount on something that is $7.05. Whatever the case... three of them and we're computing the price (or discount). The total price is $2.115 and you need to round it appropriately to $2.12 (half up).
public class Round {
public static void main(String[] args) {
double item = 0.705;
double subtotal = item * 3;
System.out.println(subtotal);
double rounded = Math.round(subtotal * 100.0)/100.0;
System.out.println(rounded);
subtotal = 2.115; // what the subtotal *should* be
rounded = Math.round(subtotal * 100.0)/100.0;
System.out.println(rounded);
}
}
However, the output of this program is:
2.1149999999999998
2.11
2.12
And there, we're off by a penny because of something that happened in the least significant digit of a floating point calculation.
Having previously worked on point of sales code that frighteningly had doubles scattered through them (I spent months converting them to an arbitrary fixed point system - I'm confident that I fixed that problem - at least in all the code I was looking at...), I can assure you that they are a real problem and the least significant digit being off by one is a big deal.
At first, this will be a "oh, its only a penny" but in this software, its about money... and people get very touchy about money being off. There are two parts to that - first is the confidence that the customer has when they see $0.705 * 3 = $2.11
when they know it should be $2.12
. The other part is that money adds up and over the course of days or weeks or months, it adds up to possibly sizable amounts when it isn't being calculated properly. This often happens in tax calculations (thats an easy way to get awkward fractions) and the agencies that collect said taxes are much less sympathetic than the customer who is off by a cent... and can do nasty things like audits.