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
 

Round

unit
System
category
arithmetic routines

declaration
function Round(X: Extended): Int64

description
Rounds a real number to nearest integer number.

If X is exactly halfway betweem two whole values, it is rounded to the one with the greatest absolute magnitude - the even number.

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 := Round(x1);
xi2 := Round(x2);
xi3 := Round(x3);
xi4 := Round(x4);

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

in real code

see also
Int, Trunc,


 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?
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.