Program to convert:
//Enter a decimal integer to output a float representation of the same memory arrangementInlinefloatI2F (inti) {floatf =0; ASSERT (sizeof(int) ==sizeof(float)); memcpy (&f, &i,4); returnF; } InlineDoubleLl2d (Long Longll) {DoubleD =0; ASSERT (sizeof(Double) ==sizeof(Long Long)); memcpy (&d, &ll,8); returnD; } /*how to ask Hovertree.com*/
Application:
inti =-1052770304;//The disassembly sees the value is this, actually is a float type, =-12.0floatf =i2f (i); printf ("f=%f\n", F); Long LongLL =0x4004000000000000l;//this is shown in memory. is actually double type 2.5DoubleD =ll2d (LL); printf ("d=%f\n", d);/*how to ask Hovertree.com*/
The principle is to replicate the memory data and then interpret it with different data types.
Recommendation: http://www.cnblogs.com/roucheng/p/cpp11.html
Programming binary/16-in-turn floating-point number (similar to reciprocal transfer)