Search code examples
delphidelphi-7

Fractional part to Int


I want to return the Fractional part of a number as an Integer value.

How can I do it?

For example I have 12.98 and I want to return 98 in an Integer variable.


Solution

  • try this

    function FractionToInt(const Precision:Integer; const Amount: Double): Integer;
    begin
      Result := Trunc(Frac(Amount) * Power(10, Precision));
    end;