convert a hexadecimal to a float32 or float64 in java

Viewed 24

i want to create a function in java :

possible INPUTs of my function (ALL IN HEXADECIAMAL) :

  • once it receives an OCTET STRING (SIZE(4))
  • once it receives OCTET STRING (SIZE(8))

so i convert whatever the input i receive (IN HEXADECIMAL) into a byte[] array :

i found on internet a function which convert from HEXADECIMAL to FLOAT:

    String myString = "HEXA-VALUE-HERE";
    Long i = Long.parseLong(myString, 16);
    Float f = Float.intBitsToFloat(i.intValue());
    return f.toString();

THE PROBLEM now how i change the function to once generate a FLOAT32 and once it generate a FLOAT64? even after hours i didnt find any exemple or whats really the difference between float32 and float64 in java

thank you in advance

0 Answers
Related