Trunc
From Lazarus wiki
Jump to navigationJump to search
│
English (en) │
suomi (fi) │
русский (ru) │
The RTL System unit contains function trunc which truncates a real-type value to an Integer-type value. It's input parameter is a real-type expression.Trunc returns a Longint value that is the value of the input parameter rounded toward zero.
Declaration
function Trunc(X: Real): Longint;
Example Usage
begin
WriteLn( Trunc(8.7) );
WriteLn( Trunc(8.3) );
WriteLn( Trunc(-8.7) );
WriteLn( Trunc(-8.3) );
end;
Output
8 8 -8 -8
See also
round
math.ceil
- round upmath.floor
- round downfrac
- returns the fractional part of a floating point valueint
- returns the integer part of a floating point valuediv
- integer division- Comparison of approaches for rounding to an integer