Skip to content Skip to sidebar Skip to footer

"unpacking" In C

I am working on rewriting a script from python to C. I'm relatively new to C. I have a variable in PYTHON which contains this values: x = [chr(113),chr(80),chr(191),chr(70)] y = '

Solution 1:

There is no need for such a function; provided the endianness is already correct the compiler can handle that case itself either through pointer casting or through a union type.

uint8_t data[4] = {113, 80, 191, 70};

printf("%f\n", (double)(*(float*)data));

...

$ ./a.out 
24488.220703

Post a Comment for ""unpacking" In C"