3.1 Floating Point Representation

In C, write a program that reads 32-bit floating point numbers from standard input and displays representation information about them.

Your program should expect any number of numbers delimited by newline characters (\n) and display the representation information one-at-a-time. When the input to the program ends, the program should exit without errors.

The representation must be displayed in the following format, as demonstrated with the input 6.0:

The floating value for 6.0 is broken out as:

   mantissa: 0x400000   or:             100 0000 0000 0000 0000 0000

   exponent: 0x81       or:   1000 0001

       sign: 0          or: 0

 in base 10: 6.000000

                        or: 0 1000 0001 100 0000 0000 0000 0000 0000

 

The program should have no other output.

You must turn in
  • A README file that contains a short write-up of your project. It should discuss the approach you took to solving the problem, it should discuss any problems or issues that still remain, it should discuss any interesting things that you learned in the course of the project. Finally, it should provide the grade you believe the project deserves with a detailed explanation of why. This explanation should almost certainly focus on why you believe the program is correct.

    This file must be in plain-text. If you need formatting, use Markdown. It must be limited to 80 characters wide, unless you are quoting program output.

  • Your source code, named a1.c.

  • A test input file, named test.in, that contains example input. It must contain at least ten (10) numbers. In addition to five (5) numbers of your choosing, it must contain these numbers:

    237.75

    -.0000005126

    -92457321.670245

    6.023E+23

    1.67339E-40

  • A test output file, named test.out, that contains the expected output for the test data.

  • A Makefile that first builds the program and then tests it by running it with test.in as the input and compares the actual output to test.out.

This assignment will be graded based on its correctness and your ability to articulate why it is correct.

You may wish to refer to convert_float_to_bits.c from class to get a few ideas.