Programmers on all sorts of platforms get this wrong all the time (I admit having done this in bad ways myself too).
In short: Don’t expect floating point values in a computer to be represented as decimals.
Rob Kennedy wrote a very nice answer on this:
The exact value 87.285 is not representable as a floating-point value in Delphi. A page on my Web site shows what that value really is, as Extended, Double, and Single:
87.285 = + 87.28500 00000 00000 00333 06690 73875 46962 12708 95004 27246 09375
87.285 = + 87.28499 99999 99996 58939 48683 51519 10781 86035 15625
87.285 = + 87.28500 36621 09375
And David Heffernan points to the best link you can get on this topic:
The classic reference on floating point is What Every Computer Scientist Should Know About Floating-Point Arithmetic.
For currency based calculations, if indeed this is, you should use a base 10 number type rather than base 2 floating point. In Delphi that means `Currency`.
–jeroen
via delphi – Why is the result of RoundTo(87.285, -2) => 87.28 – Stack Overflow.