Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top