function Round (x: Real): Integer;
Round returns the nearest integer to x. The result is of type integer. In the case of equidistance, the result is machine-dependent (or depends on the behaviour of the processor).
Round is defined in ISO 7185 Pascal and supported by all known Pascal variants.
program RoundDemo; var Foo: Real; begin Foo := 9.876543; WriteLn (Round (Foo)); { Prints 10 } Foo := 3.456789; WriteLn (Round (Foo)); { Prints 3 } 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.
Real Types, Real, Int, Frac, Trunc.