How can I find information about float
datatype in C? I mean the bit struct for this type (decimal, signal indicator, etc...)?
Let me explain what I'm trying to do:
I am implementing an network protocol and I need to send 6 octects with Latitude and Longitude (according to protocol documentation). First 3 octects must have LAT information and last 3 must have LON information.
I can't use bitwise operators in float
datatype, so for debug, I'm copying memory of float
variable to a new uint32_t
variable (both 4-bytes wide) and then, trying to shift bit's to get the correct value, but it's not working.
This is the code that I'm using to test/debug conversion:
int32_t b = 0;
memcpy(&b,&a,4);
int32_t c = (b >> 23);
printf("Valor de C: 0x%X, Decimal: %d\n",c,c);
// Should print only '23', but it's printing
// Valor de C: 0x41B, Decimal: 1051
After 'knowing' the correct bit-position of float, I'll copy those bit's to my protocol data, which is an array of unsigned char[6] (this I can't change the type, only values).