Thema: Delphi Count digits after point

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Count digits after point

  Alt 15. Feb 2014, 15:10
Delphi-Version: 2010
I need to know how many digits has float number after point.

Delphi-Quellcode:
function CountDigitsAfterPoint(AValue: Extended): Byte;
begin
  Result := 0;

  while (Frac(AValue) <> 0) do
  begin
    Inc(Result);
    AValue := AValue * 10;
  end;
end;
Working good in most cases, but not for all

Incorect results for sample data:
2.048 --> 19
8.448 --> 19
565.148 --> 17
32.064 --> 18
274.176 --> 17
97.728 --> 17
155.52 --> 17
622.08 --> 17



Please help
  Mit Zitat antworten Zitat