Node: Trunc, Next: Truncate, Previous: True, Up: Reference

### Trunc

#### Synopsis

         function Trunc (x: Real): Integer;

#### Description

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

#### Conforming to

`Trunc` is defined in ISO 7185 Pascal and supported by all known Pascal variants.

#### Example

         program TruncDemo;

         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, Int, Frac, Round.