How to convert hexadecimal into floating point?

I'm communicating with a Modbus device that uses IEEE 754 floating point format.
I'm trying to convert 4 different hex registers that i receive from device through getc() into a float variable using IEEE 754 format.
I tried saving those hex register into char and convert it to float using union but the main problem is that for example 0x10 will be recognized as 10 in decimal instead of 16 in decimal.

For example, i receive 4 different hex register (43, 70, 80, 00 ). The output should be 240.5 but i got 0.

Incorrect value with this function.
union {
    char c[4];
    float f;
} conv;

Any solution for this?
Last edited on
Topic archived. No new replies allowed.