Altera_Forum
Honored Contributor
16 years agoCombine 4 bytes in float
Hi all!
i'm receiving a float (32bit) from the serial port... i receive the correct sequence but now i'm trying to recombine the number with this code: unsigned char b1,b2,b3,b4; b1=GetUart(); b2=GetUart(); b3=GetUart(); b4=GetUart(); coeff = (float)((b4&0xFF) | ((b3<<8)&0xFF00) | ((b2<<16)&0xFF0000) | ((b1<<24)&0xFF000000)); i'm sending pigreco (for example) and receive the bytes: 0xdb,0x0f,0x49,0x40 that is the correct value, just swap. but if i print the value result coeff :3.675212e+09 any idea??