/* This program illustrates that a string of bits can be interpreted      */
/*  in many ways.                                                         */
/* C. D. Cantrell, June 1996                                              */
/*                                                                        */
/* You will need to uncomment the following line for many C compilers.    */
/* #include <stdio.h> */
main()
{
/* variable declarations */
  char ch;            /* ch is a character (1 byte)                       */
  int pos, *p;        /* pos is an integer; p points to an integer, *p    */
  int neg;            /* if default integer size is 16 bits, use long int */
  float f;            /* f is a 32-bit floating-point number              */
/* assignments */
  ch = 'C';           /* ch gets ASCII code for uppercase 'C'             */
  pos = 32767;        /* pos gets positive integer 32,767                 */
  neg = -32767;       /* neg gets additive inverse of pos                 */
  f = 32767.0000;     /* f gets 32,767, expressed in decimal reprn.       */
  p = &pos;           /* p now points to pos                              */
/* output */
  printf("ch (character) = %c\n",ch);         /* print ch as a character, */
  printf("ch (decimal integer) = %d\n",ch);   /*  unsigned int (base 10), */
  printf("ch (fp no.) = %e\n",ch);            /*  as a fl.-pt. number,    */
  printf("ch (hex) = %x\n",ch);               /*  & in base 16 (unsigned) */
  printf("pos (decimal integer) = %d\n",pos); /* print pos in base 10 rp.,*/
  printf("pos (fp no.) = %e\n",pos);          /*  as a fl.-pt. number,    */
  printf("pos (hex) = %x\n",pos);             /*  & in base 16 (unsigned) */
  printf("neg (signed) = %d\n",neg);          /* print neg as a signed    */
  printf("neg (unsigned) = %u\n",neg);        /*  and an unsigned int,    */
  printf("neg (fp no.) = %e\n",neg);          /*  as a fl.-pt. number,    */
  printf("neg (hex) = %x\n",neg);             /*  & in base 16 (unsigned) */
  printf("pointer to pos (hex address) = %p\n",p); /* p in base 16 reprn. */
  printf("f (decimal fraction) = %6.6f\n",f); /* f as a fraction (base 10)*/
  printf("f (fp no.) = %e\n",f);              /*  in sci. notation,       */
  printf("f (decimal integer) = %d\n",f);     /*  as an int (base 10 rep.)*/
  printf("f (hex) = %x\n",f);                 /*  & in base 16 (unsigned) */
  printf("newline (character) = %c\n",'\n');  /* newline in usual form,   */
  printf("newline (decimal integer) = %d\n",'\n'); /* signed decimal int, */
  printf("newline (fp no.) = %e\n",'\n');     /*  as a fl.-pt. number,    */
  printf("newline (hex) = %x\n",'\n');        /*  & in base 16 (unsigned) */
}

