Float to intger conversion

General discussion on mikroC PRO for 8051.
Post Reply
Author
Message
hussien
Posts: 7
Joined: 14 Dec 2008 04:16

Float to intger conversion

#1 Post by hussien » 18 Oct 2009 22:06

hi,
i want to ask how to convert from float to int in c
thanks

nart_schinackow
Posts: 122
Joined: 28 Apr 2009 16:16

Re: Float to intger conversion

#2 Post by nart_schinackow » 08 Feb 2010 06:59

hey !

the easiest way to do this is TYPE CASTING, and to do this here is an example!!

Code: Select all

float x= 1.3;
float y=1.5;
int z=0;
int sum;
//we could say
z=(int)x;// in this case the value stored in z is 1
z=(int)y;//new value will be inserted into x and will be also 1
sum=(int)(x+y);




just go to the index help and type their type casting!

good luck

Post Reply

Return to “mikroC PRO for 8051 General”