float f = 8.69f;
int a = Float.floatToIntBits(f);
String floatStr = Integer.toBinaryString(a);
double d1 = f;
long b = Double.doubleToLongBits(d1);
String convertStr = Long.toBinaryString(b);
double d2 = 8.69;
long c = Double.doubleToLongBits(d2);
String doubleStr = Long.toBinaryString(c);
System.out.println(floatStr);
System.out.println(convertStr);
System.out.println(doubleStr);
the output is :
1000001000010110000101000111101 100000000100001011000010100011110100000000000000000000000000000 100000000100001011000010100011110101110000101000111101011100001
When convert float to double, why the jvm only copy bits from float, then adding zeros to the rest bits of the double, rather than calculate the real bits like the third line in output.