Java, convert floating-point Hexadecimal value

5

I'm developing an application that receives data from a GPS card, data is received by bluetooth in hexadecimal, latitude and longitude values are 64-bit floating points, which follows the IEEE 754 standard.

I can already capture the hexadecimal values I need for a String variable. For example:

  

b3baf6e3530b38c0 (latitude)

     

ff198e4d752f4ac0 (longitude)

But I am not able to make this String with the hexadecimal value in the latitude and longitude values, for example: -24.123456789 and -52.123456789.

Does anyone know of any way to interpret the hexadecimal value of a floating point for a double variable?

    
asked by anonymous 03.02.2017 / 17:54

1 answer

3

The answer is that the values received from the card transmitting the GPS are coming in a mirrored way, so it was not getting the actual values. then the value b3baf6e3530b38c0 is actually c0380b53e3f6bab3 To perform the conversion, I've used the following code:

public double hexToDouble(String hexvalue){
    return Double.longBitsToDouble(new BigInteger(hexvalue,16).longValue());
}
    
03.02.2017 / 19:24