How to convert a hexadecimal string to a single floating point in Java?
For example, how to implement:
float f = HexStringToFloat ("BF800000"); // f should now contain -1.0
I ask about this because I tried:
float f = (float)(-1.0); String s = String.format("%08x", Float.floatToRawIntBits(f)); f = Float.intBitsToFloat(Integer.valueOf(s,16).intValue());
But I get the following exception:
java.lang.NumberFormatException: for input line: "bf800000"
java string floating-point hex
apalopohapa
source share