however if I'm not mistaken, on the Uno and other ATMEGA based boards for example, 'double' occupies 4 bytes and therefore depending on the arduino board you are using, the above code may (or may not!) work.
for the above code to work correctly for your conversion, 'double' and 'long' BOTH need to be 8 bytes wide.
OK! By reverse engineering (see the sketch below), I have found your both float and hex values are correct; the data comes in 64-bit binary64/IEEE-754 Floating Point Format(Fig-1). You can apply this trick in the solution of your problem. Sketch: (tested in DUE)
union
{
double x ;
long long y;
}data;
void setup()
{
Serial.begin(9600);
data.y = 0x4104E8D000000000;
Serial.println(data.x, 1); //shows: 171290.0
}
void loop()
{
}
sherzaad:
for the above code to work correctly for your conversion, 'double' and 'long' BOTH need to be 8 bytes long.
In UNO/NANO/MEGA: float and double refer to the same data size of 32-bit (4-byte) in binary32 format (Fig-1) for the representation/storage of floating point number.
In DUE: float refers to 32-bit data size in binary32 format(Fig-1) and double refers to 64-bit (8-byte) data size in binary64 format (Fig-2) for the representation/storage of floating point number.
long data type:
It refers to a 32-bit (4-byte) data size for integer signed numbers in all Arduinos (range:0x80000000 to 0x7FFFFFFF).
It includes the IEEE 64 bit float specification and also the packet format which the OP gave an example of: Packet: 7eff01466600000000d0e80441577e (Hex)
The 7E at the beginning and end of the packet is a delimiter and cannot appear in the body of the packet. That is, if that double which is encoded in the packet, just happens to contain a '7E', then it has to be escaped according to a rule in the specification (Table 1 - OBC packet formats). Conversely, if the OP is attempting to decode a packet, he has to undo any escaping before converting the number it contains.