/* Standard C Program: Read IEEE 32-bit Floating Point */

#include <stdio.h>
#include <math.h>
int main ( void ) {
  int s, e, f, power;
  printf("IEEE reader: Enter 32 bits, each 0 or 1:\n");
  s = ( getchar()=='0' ) ? '+' : '-' ; /* sign */
  for( e=0, power=1<<7 ; power>0 ; power/= 2 )
    if( getchar()=='1' ) e += power;   /* exponent */
  for ( f=0, power=1<<22 ; power>0 ; power/=2 )
    if( getchar()=='1' ) f += power;   /* mantissa */
  if( e==255 )
    if( f==0 ) printf("%c infinity", s);
    else printf("NaN");
  else
    if( e==0 )
      if( f==0 ) printf("%c 0", s);
      else printf("%c %.7e (subnormal)",
            s, pow(2.0,-126.0)*(f/(double)(1<<23)) );
    else printf("%c %.7e",
          s, pow(2.0,e-127.0)*(1.0+f/(double)(1<<23)));
  putchar('\n');
  return 0;
}
