/* A short program to see what signed-magnitude decimal floating point number*/ /* is represented by the binary bit pattern in a memory location, where the */ /* 32-bit number is represented in hexadecimal shorthand for an IEEE754 */ /* single-precision floating point number format; and vice versa. */ /* In these cases, we ignore the compiler warnings from the -Wall option to */ /* the effect that we are assigning the wrong type of values to the pointers.*/ /* C. Silio */ /* May 9, 2009 */ #include void main(void){ /* */ /* Hex representation to floating point value output */ /* */ unsigned int num1 = 0xC13C0000; float* fnum1; /* let fnum1 think it points at a float value */ fnum1 = &num1; /* point fnum1 to the address num1 */ printf("num1 = 0x%x\t fnum1 = %f \n", num1, *fnum1); /* print the value in the memory location to which fnum1 points */ /* */ /* Floating point value to hexadecimal representation output */ /* */ float fnum2 = -7.125; unsigned int *num2; num2 = &fnum2; printf("num2 = 0x%x\t fnum2 = %f \n", *num2, fnum2); return; }