Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to convert a double to an integer?

Status
Not open for further replies.

Han777

Programmer
Dec 12, 2007
19
What's the most direct way to convert a double to an integer?
 
More specifically to produce the floor or ceiling of a double and save the result to an integer.
 
won't trunc work?

Code:
var
  a: double;
  b: integer;
begin
  a := 3.14159;
  b := trunc(a);
  label1.caption := IntToStr(b);
end;

If not, you'll need to be a whole lot more specific as to what you are looking for.
 
check the Math unit for functions floor and ceil.

depends on what delphi version you have though...

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top