CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

float to int

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zrbz



Joined: 16 Jul 2007
Posts: 2

View user's profile Send private message

float to int
PostPosted: Mon May 26, 2008 1:39 am     Reply with quote

how do i convert my int value into a float value?

can i do this?

int x;
float y;

x=y;
Ttelmah
Guest







PostPosted: Mon May 26, 2008 3:30 am     Reply with quote

Yes.
Why not just try it?.
This is standard C. Implicit type conversion will take place. So x=y will work, as will y=x (the latter will 'lose' the fractional part).

Best Wishes
golf
Guest







PostPosted: Mon May 26, 2008 3:37 am     Reply with quote

x is int so, you will lose fractional part;
if you are unsure of the behaviour of the compiler you can make a casting

x = (int)y;

variable y will be integer and assigned to x (compiler makes this by default)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group