Unable to understand o / p of Float.toHexString () method in java

I want to know how to get the hexadecimal representation of a float number. I tried the following code

      System.out.println(Float.toHexString(56)); 

Got o / p

  0x1.cp5 

I really do not understand. If I use Integer method, then o / p will be 38, which I can understand ... but how does o / p come about 0x1.cp5. Can someone tell me or point to a good tutorial.

+4
source share
2 answers

Use this tool to find out what will happen to your float if it is introduced in IEEE 754 . 56 in binary format 111000, which when normalized is converted to 1.11000.

javadoc, 0x1. significand, "1100" , is 'c' . 5.

+1

java.lang.Float javadocs:

http://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#toHexString%28float%29

  • m , . ​​ "0x1". . , , . , "p", , Integer.toString .
  • m - , "0x0". . . , "p-126". , .
+3

Source: https://habr.com/ru/post/1538533/


All Articles