I'm trying to convert a string of HEX to a single float value. The string is 4 bytes long. It was defined as:
String B = "";
It is a substring of a longer string:
B = input.substring(6,14);
This results in the string I am trying to convert in to a single float value.
Online I found following code:
float y = *(float*)&B;
This compiles without an error, but when I run the code it's always 0.000000
. I'm guessing I can't use that function with a string. A typical string can be "bb319ba6"
which should be -0.002710083
. For that I'm using a IEEE 754 converter I found online.
I basically need to do the same conversion on the Arduino. I hope somebody can help me with that.