Integer/fractional part of number

Posted in Mathematics

Use Int function, if you want to get integer part of real number and Fruc function for getting fractional part of it.

procedure TForm1.Button1Click(Sender: TObject);
var
  Number: Real;
begin
  Number:=StrToFloat(Edit1.Text);
  Label2.Caption:=
    'Integer part is '+
    FloatToStr(Int(Number));
  Label3.Caption:=
    'Fractional part is '+
    FloatToStr(Frac(Number));
end;