Forum Discussion
Altera_Forum
Honored Contributor
15 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=GetUa...
Altera_Forum
Honored Contributor
15 years agothanks!
i've never userd this function "union" by the way, the compiler say me: ../acquisition_6.c:78: error: `b' undeclared (first use in this function) ../acquisition_6.c:78: error: (Each undeclared identifier is reported only once ../acquisition_6.c:78: error: for each function it appears in.) ../acquisition_6.c:83: error: incompatible type for argument 1 of `printf' but the code is: --- Quote Start --- void ParseCoeff(){ [...] union { unsigned char b[4]; float f; } x; if (UartHasFourByte()){ b[1] = GetUart(); b[2] = GetUart(); b[3] = GetUart(); b[4] = GetUart(); coeff = x.f; [...] --- Quote End ---