Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2007, 09:11 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default Single to integer.

This could be simple, but have no time to search:

How to convert a single type to integer type and vies versa?

Regards,
Abdulaziz Jasser
Reply With Quote
  #2  
Old 01-16-2007, 09:40 AM
cyberk cyberk is offline
Junior Member
 
Join Date: Oct 2001
Posts: 23
Default RE: Single to integer.

uses Math;
var
mysingle: single;
myinteger: integer;
begin
myinteger:=10;
mysingle:=myinteger;

myinteger:=round(mysingle); //to round the single
myinteger:=trunc(mysingle); //to trunc the single
myinteger:=floor(mysingle); //round down
myinteger:=ceil(mysingle); //round up
end;


accept this as an answer if that helps
Reply With Quote
  #3  
Old 01-16-2007, 10:10 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Single to integer.

I actually did some tests after my post and found a lot of ways to do it. However thanks.

Regards,
Abdulaziz Jasser
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:25 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.