in c way:
#include <stdio.h>
typedef union {
float f;
unsigned u;
} ufloat;
int main(void)
{
ufloat u1;
u1.f = 0.01f;
printf("%x\n", u1.u);
}
in java way:
public class FloatMulti {
public static void main(String[] args) {
System.out.println(Integer.toHexString(Float.floatToIntBits(0.01f)));
System.out.println(Long.toHexString(Double.doubleToLongBits(0.01)));
}
}
参考资料:
How do I display the binary representation of a float or double?