#include #include // Don't try this at home // // 3.14 = 40091EB851EB851F (in double format) // On a Little-Endian (x86) 32-bit machine this is stored as: // // 51EB851F (1374389535 in decimal) // 40091EB8 (1074339512 in decimal) // // Therefore // double pi=3.14; // printf("pi=%d\n", pi); // // Returns: 1374389535 // and // printf("pi=%d %d\n", pi); // // Returns 1374389535 1074339512 // Another Example: // 2.0 = 40000000 00000000 // Which is stored as // // 00000000 (0 in decimal) // 40000000 (1073741824 in decimal) // // Thus // double b=2.0; // printf("b=%d\n", b); -> 0 // printf("b=%d %d\n", b); -> 0 1073741824 // // Prints int main() { double pi=3.14; printf("pi=%d\n", pi); printf("pi=%d %d\n\n", pi); double b=2.0; printf("b=%d\n", b); printf("b=%d %d\n", b); // The second %d uses the extra bytes of the double b that were not printed the first time system("pause"); return 0; }