labDataRepresentation

 

Due Date

See the calendar for due date.

Objectives:

Description:

For this lab, you get to display the values for the following integers: Additionally, you get to display all possible positive floating point numbers in ascending order. Your code should work for numbers with 2 to 32 bits.

Requirements:

  1. Your program must compile and run on system64 with the following command:
    gcc -Wall --std=c11 -pedantic *.c -o labDataRepresentation
  2. Do not include spaces in directory names or file names.
  3. For full credit, output needs to match exactly to the following examples:
    labDataRepresentation-answerKey6_3.txt:
    Please enter the total number of bits: 
    
    For 6 bits:
    Number	Decimal	Hex	Binary
    UMin	0	0x00	000000
    UMax	63	0x3F	111111
    TMin	-32	0x20	100000
    -1	-1	0x3F	111111
    TMax	31	0x1F	011111
    
    Please enter the number of exponent bits: 
    
    Positive floating point values for 3 Exp bits and 2 Frac bits:
    S Exp Frac Value
    0 000 00 0.000000
    0 000 01 0.062500
    0 000 10 0.125000
    0 000 11 0.187500
    0 001 00 0.250000
    0 001 01 0.312500
    0 001 10 0.375000
    0 001 11 0.437500
    0 010 00 0.500000
    0 010 01 0.625000
    0 010 10 0.750000
    0 010 11 0.875000
    0 011 00 1.000000
    0 011 01 1.250000
    0 011 10 1.500000
    0 011 11 1.750000
    0 100 00 2.000000
    0 100 01 2.500000
    0 100 10 3.000000
    0 100 11 3.500000
    0 101 00 4.000000
    0 101 01 5.000000
    0 101 10 6.000000
    0 101 11 7.000000
    0 110 00 8.000000
    0 110 01 10.000000
    0 110 10 12.000000
    0 110 11 14.000000
    0 111 00 inf
    0 111 01 NaN
    0 111 10 NaN
    0 111 11 NaN
    
    and labDataRepresentation-answerKey8_4.txt:
    Please enter the total number of bits: 
    
    For 8 bits:
    Number	Decimal	Hex	Binary
    UMin	0	0x00	00000000
    UMax	255	0xFF	11111111
    TMin	-128	0x80	10000000
    -1	-1	0xFF	11111111
    TMax	127	0x7F	01111111
    
    Please enter the number of exponent bits: 
    
    Positive floating point values for 4 Exp bits and 3 Frac bits:
    S Exp Frac Value
    0 0000 000 0.000000
    0 0000 001 0.001953
    0 0000 010 0.003906
    0 0000 011 0.005859
    0 0000 100 0.007812
    0 0000 101 0.009766
    0 0000 110 0.011719
    0 0000 111 0.013672
    0 0001 000 0.015625
    0 0001 001 0.017578
    0 0001 010 0.019531
    0 0001 011 0.021484
    0 0001 100 0.023438
    0 0001 101 0.025391
    0 0001 110 0.027344
    0 0001 111 0.029297
    0 0010 000 0.031250
    0 0010 001 0.035156
    0 0010 010 0.039062
    0 0010 011 0.042969
    0 0010 100 0.046875
    0 0010 101 0.050781
    0 0010 110 0.054688
    0 0010 111 0.058594
    0 0011 000 0.062500
    0 0011 001 0.070312
    0 0011 010 0.078125
    0 0011 011 0.085938
    0 0011 100 0.093750
    0 0011 101 0.101562
    0 0011 110 0.109375
    0 0011 111 0.117188
    0 0100 000 0.125000
    0 0100 001 0.140625
    0 0100 010 0.156250
    0 0100 011 0.171875
    0 0100 100 0.187500
    0 0100 101 0.203125
    0 0100 110 0.218750
    0 0100 111 0.234375
    0 0101 000 0.250000
    0 0101 001 0.281250
    0 0101 010 0.312500
    0 0101 011 0.343750
    0 0101 100 0.375000
    0 0101 101 0.406250
    0 0101 110 0.437500
    0 0101 111 0.468750
    0 0110 000 0.500000
    0 0110 001 0.562500
    0 0110 010 0.625000
    0 0110 011 0.687500
    0 0110 100 0.750000
    0 0110 101 0.812500
    0 0110 110 0.875000
    0 0110 111 0.937500
    0 0111 000 1.000000
    0 0111 001 1.125000
    0 0111 010 1.250000
    0 0111 011 1.375000
    0 0111 100 1.500000
    0 0111 101 1.625000
    0 0111 110 1.750000
    0 0111 111 1.875000
    0 1000 000 2.000000
    0 1000 001 2.250000
    0 1000 010 2.500000
    0 1000 011 2.750000
    0 1000 100 3.000000
    0 1000 101 3.250000
    0 1000 110 3.500000
    0 1000 111 3.750000
    0 1001 000 4.000000
    0 1001 001 4.500000
    0 1001 010 5.000000
    0 1001 011 5.500000
    0 1001 100 6.000000
    0 1001 101 6.500000
    0 1001 110 7.000000
    0 1001 111 7.500000
    0 1010 000 8.000000
    0 1010 001 9.000000
    0 1010 010 10.000000
    0 1010 011 11.000000
    0 1010 100 12.000000
    0 1010 101 13.000000
    0 1010 110 14.000000
    0 1010 111 15.000000
    0 1011 000 16.000000
    0 1011 001 18.000000
    0 1011 010 20.000000
    0 1011 011 22.000000
    0 1011 100 24.000000
    0 1011 101 26.000000
    0 1011 110 28.000000
    0 1011 111 30.000000
    0 1100 000 32.000000
    0 1100 001 36.000000
    0 1100 010 40.000000
    0 1100 011 44.000000
    0 1100 100 48.000000
    0 1100 101 52.000000
    0 1100 110 56.000000
    0 1100 111 60.000000
    0 1101 000 64.000000
    0 1101 001 72.000000
    0 1101 010 80.000000
    0 1101 011 88.000000
    0 1101 100 96.000000
    0 1101 101 104.000000
    0 1101 110 112.000000
    0 1101 111 120.000000
    0 1110 000 128.000000
    0 1110 001 144.000000
    0 1110 010 160.000000
    0 1110 011 176.000000
    0 1110 100 192.000000
    0 1110 101 208.000000
    0 1110 110 224.000000
    0 1110 111 240.000000
    0 1111 000 inf
    0 1111 001 NaN
    0 1111 010 NaN
    0 1111 011 NaN
    0 1111 100 NaN
    0 1111 101 NaN
    0 1111 110 NaN
    0 1111 111 NaN
    
  4. Make a file named rubric-yourlastname.txt in your project directory with a completed rubric. Specify estimated points for each entry including the number of hours spent.
  5. Include a Makefile in your submission such that running make will correctly compile your code.

Submission

Before submitting your lab, remove all object (.o) files (for example, with a make clean command). Make a gzipped tarball (.tgz) of the directory with your .c, Makefile and rubric-yourlastname.txt files. Submit your tarball at https://3240.cs.mtsu.edu/. For further instructions, please see the Miscellaneous page.

Rubric:

Points       Item
----------   --------------------------------------------------------------
_____ / 10   Documentation (applies to new and modified files):
             All source code files (.h & .c) include file name, author, description etc.
             Functions and variables
             + All non-trival variables are commented
             + All functions preceded by brief comments
             + Comments included before major portions of code
             + Functions should be no longer than 1 page
_____ / 88   Correct output (matches the format of the example & demonstrates correct execution)
_____ /  0   Compiles and runs on system64
_____ /  2   Completed rubric (estimates for each line including hours spent)
             
_____ /100   Total


_____  Approximate number of hours spent
      

Notes

  1. Start small. Write your comments first. Then, add in code and test it a little at a time.
  2. Part of the grading process is automated by using diff. You should verify that your output matches the above output exactly with the following commands on ranger:
    make  # or  gcc  -Wall  --std=c11  -pedantic  *.c  -o labDataRepresentation-yourlastname
    (echo "6"; echo "3")  | ./labDataRepresentation-yourlastname  > output6_3.txt
    diff  /nfshome/hcarroll/public_html/3240/private/labs/labDataRepresentation-answerKey6_3.txt  output6_3.txt
    (echo "8"; echo "4")  | ./labDataRepresentation-yourlastname  > output8_4.txt
    diff  /nfshome/hcarroll/public_html/4240/private/labs/labDataRepresentation-answerKey8_4.txt  output8_4.txt
    
    If the two files match exactly (which is what you want) then there should be NO output from diff. If diff shows one or more differences, fix them and run it again. To get side-by-side output (with the answer key on the left and your output on the right), replace the last line with:
    diff  --side-by-side  /nfshome/hcarroll/public_html/3240/private/labs/labDataRepresentation-answerKey6_3.txt  output6_3.txt
    For details about interpreting the output of diff, see the Using diff section on the Misc. webpage.