@chutem: Yes, I want the extra zeros removed. My English fails me sometimes. The problem is that I receive a string value (take 3.5 for an example) which I want to convert to a single. The function StrToFloat will store the extra zeros as well, though, and I see no reason why I should iterate through the complete string until I find the part where only zeros are stored.
My new approach was this:
function floattostr2(const val:single):string;
var i,j,lastnum:byte;
begin
result := floattostr(roundto(val,2));
for i := 1 to length(result) do
if copy(result,i,i) = '.' then begin
for j := i+1 to length(result) do
if copy(result,j,j) <> '0' then lastnum := j;
result := copy(result,1,lastnum);
end;
end;
But it failed as well.