Float data convert to Byte

Status
Not open for further replies.

M_kashif

Newbie level 3
Joined
Jan 19, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Dear all please tell me how to convert the float data in byte in mickroc compiler...

thanks
 

the float data type is a 32bit value, if you convert it to a variable that uses only one byte like an unsigned char then you will loose all the decimals and you can only represent integers from 0 to 255 (0b00000000 to 0b11111111).

Assuming that the value can fit in 8bits and you don't mind truncating the decimals you can use (unsigned char)my_float_variable
Are the float values higher than zero or they can be negative too?
 

Thanks i am try this and its working.
thanks
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…