Difference between revisions of "Trunc"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 
{{Trunc}}
 
{{Trunc}}
 +
 +
<div class="floatright">
 +
[[Image:trunc.png|100px]]
 +
</div>
  
 
The [[RTL]] [[System unit]] contains [[Function|function]] '''trunc''' which truncates a [[Real|real]]-type value to an [[Integer]]-type value.
 
The [[RTL]] [[System unit]] contains [[Function|function]] '''trunc''' which truncates a [[Real|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.
 
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.
  
[[Image:trunc.png]]
 
  
 
== Declaration ==
 
== Declaration ==

Revision as of 21:18, 26 September 2019

English (en) suomi (fi) русский (ru)

trunc.png

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