Greeting,

Did anyone know how to use FloatToStrF without zero padding? I need it because 
my code must avoid the usage of scientific notation, thus I used FloatToStrF 
with ffFixed format. But later I found out that the output of resulted string 
was padded with zeros. For temporarily, I use these code to remove all zero 
padding but still there must be some way which is more efficient...

---code begin---
function TDMod.FloatToStrNP(val : extended) : string ;
var
  a : integer ;
  txt,retval : string ;
begin
  txt := FloatToStrF(val,ffFixed,18,18) ;
  retval := '' ;
  for a:=Length(txt) downto 1 do
  begin
    if (txt[a]='0') and (retval <> '') then retval := txt[a]+retval
    else if txt[a]<>'0' then retval := txt[a]+retval ;
  end ;
  Result := retval ;
end;
---code end---

---------------------
CoolKid K-Qha
http://kha.web.id
---------------------


      

Reply via email to