1. Home
  2. Computing & Technology
  3. Delphi Programming
Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

Trunc

unit
System
category
arithmetic routines

declaration
function Trunc(X: Extended): Int64

description
Truncates a real number to an integer number.

Trunc converts real X to integer by simply removing any fractional part of X.

example
var x1,x2,x3,x4 : extended;
    xi1,xi2,xi3,xi4 : integer;
	
x1 := 2.4;
x2 := -2.4;
x3 := 2.5;
x4 := -2.5;

xi1 := Trunc(x1);
xi2 := Trunc(x2);
xi3 := Trunc(x3);
xi4 := Trunc(x4);

//xi1 = 2
//xi2 = -2
//xi3 = 2
//xi4 = -2

in real code

see also
Int, Round,


 Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?
Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.