title: How to convert hex string to float in Java?
body: <p>How to convert hexadecimal string to single precision floating point in Java?</p>
  
  <p>For example, how to implement:</p>
  
  <p>float f = HexStringToFloat("BF800000"); // f should now contain -1.0</p>
  
  <p>I ask this because I have tried:</p>
  
  <pre><code>float f = (float)(-1.0);
  String s = String.format("%08x", Float.floatToRawIntBits(f));
  f = Float.intBitsToFloat(Integer.valueOf(s,16).intValue());
  </code></pre>
  
  <p>But I get the following exception:</p>
  
  <p>java.lang.NumberFormatException: For input string: "bf800000"</p>