Keep in mind the nature of floating point numbers. For an example in base-10 -- how can you directly represent a number such as (1/3) with a finite amount of digits (remembering that those threes will keep going...). The same applies for singles/doubles in base-2 -- there are some numbers you can't represent exactly with the allocated amount of bits, so there will be some round-off error creeping in sometimes. Now, I'm not sure that this is the case here, but it may well be that your given numbers coincidentally have this problem. If you increase your precision (from singles to doubles or extended) and the problem goes away then you're fit to go.

The above is also the same reason that you shouldn't compare two floating point numbers directly (if a = b), but should always use an epsilon instead (maybe something like (if abs(a - b) < epsilon) where epsilon is a smallish number (maybe 1e-6 or something), off the top of my head).

Maybe the above doesn't apply in your case, though. At least you've found a solution!

Incidentally, would the following not do what you wanted?

[pascal]procedure TForm1.Button1Click(Sender: TObject);
var
str: string;
begin
str := Format('%4.2f', [24.342343]);
ShowMessage(str);
end;[/pascal]