im looking for a way to get a double value to follow the IEEE 754 standard, iv seen a number of librarys for it on java but i had my doubts to whether it was a problem that wasnt solved already with a java standard library. The value i am expecting in hex is :

66 66 66 66 C6 4B 40 

or 55.55 in decimal.
However using a standard floating point number in java produces the following :

double f = 55.55;

Which im pretty sure is either the wrong standard/order for the floating point number i wish to output to the file i am working with. So does anyone know how to set a floating point number to IEEE 754 standard is my question :)

Edited by trishtren

4 Years
Discussion Span
Last Post by trishtren

Take a look at this. Basically, you'll want to use Double.toLongBits(f) or Double.toRawLongBits(f) (the difference between the two pertains to NaN values; see the documentation). These will give you a long integer, which you should be able to use Long.toHexString() to get the actual IEEE 754 value.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.