Node:Int, Next:, Previous:Insert, Up:Reference



Int

Synopsis


function Int (x: Real): Real;

Description

Int returns the integer part of a floating point number as a floating point number. Use Trunc to get the integer part as an integer.

Conforming to

Int is a UCSD Pascal extension.

Example


program IntDemo;

begin
  WriteLn (Frac (12.345) : 1 : 5);  { 0.34500 }
  WriteLn (Int (12.345) : 1 : 5);  { 12.00000 }
  WriteLn (Round (12.345) : 1);  { 12 }
  WriteLn (Trunc (12.345) : 1);  { 12 }

  WriteLn (Frac (-12.345) : 1 : 5);  { -0.34500 }
  WriteLn (Int (-12.345) : 1 : 5);  { -12.00000 }
  WriteLn (Round (-12.345) : 1);  { -12 }
  WriteLn (Trunc (-12.345) : 1);  { -12 }

  WriteLn (Frac (12.543) : 1 : 5);  { 0.54300 }
  WriteLn (Int (12.543) : 1 : 5);  { 12.00000 }
  WriteLn (Round (12.543) : 1);  { 13 }
  WriteLn (Trunc (12.543) : 1);  { 12 }

  WriteLn (Frac (-12.543) : 1 : 5);  { -0.54300 }
  WriteLn (Int (-12.543) : 1 : 5);  { -12.00000 }
  WriteLn (Round (-12.543) : 1);  { -13 }
  WriteLn (Trunc (-12.543) : 1);  { -12 }
end.

See also

Real Types, Real, Frac, Round, Trunc.