#include int main (void) { /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ #ifdef WORDS_BIGENDIAN # define LDBL80_WORDS(exponent,manthi,mantlo) \ { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ (unsigned int) (mantlo) << 16 } #else # define LDBL80_WORDS(exponent,manthi,mantlo) { mantlo, manthi, exponent } #endif { puts ("Pseudo-Infinity"); static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; printf ("%Lf\n", x.value); printf ("%Le\n", x.value); printf ("%Lg\n", x.value); } { puts ("Pseudo-Zero"); static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; printf ("%Lf\n", x.value); printf ("%Le\n", x.value); printf ("%Lg\n", x.value); } { puts ("Unnormalized number"); static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; printf ("%Lf\n", x.value); printf ("%Le\n", x.value); printf ("%Lg\n", x.value); } { puts ("Pseudo-Denormal"); static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; printf ("%Lf\n", x.value); printf ("%Le\n", x.value); printf ("%Lg\n", x.value); } return 0; }