CMPS-2240 Lab-15

Gordon Griesel
Department of Computer and Electrical Engineering and Computer Science
California State University, Bakersfield

Pablo's lab

Gordon's lab is below
---------------------

Goal: Extend your 2240/d/ieee754.c program.

Start with your ieee754.c program.
program

Copy the program to 2240/f/ieee754.c

Do your work in the 2240/f folder.

Modify your program to accept a binary bit string as a command-line argument.

This bit string will be the bits of a 32-bit floating-point number.

Convert the bits to a floating-point value, and display the value.

Note:
The program will also work as before.
Detect a float value like this...
   If command-line argument has a decimal-point, it's a float value.
   If command-line argument has no decimal-point, it's some binary bits.

See sample output below.

Convert a real number to IEEE 754 binary bits...
$ ./a.out 25.25 decimal point found f: 25.250000000000000000000000 i: 1103757312 your floating point bits are: 0 10000011 10010100000000000000000
Convert the bits above to a float value.
$ ./a.out 01000001110010100000000000000000 no decimal point found f: 25.250000000000000000000000 i: 1103757312 your floating point value for these bits is: 25.250000
Convert 123.456
$ ./a.out 123.456 decimal point found f: 123.456001281738281250000000 i: 1123477881 your floating point bits are: 0 10000101 11101101110100101111001
Notice that 32-bit float is accurate to 7 digits.
$ ./a.out 01000010111101101110100101111001 no decimal point f: 123.456001281738281250000000 i: 1123477881 your floating point value for these bits is: 123.456001
How to do it: ------------- Put the command-line bits into your num.i member variable. Argument is a string, so read through the string characters and populate the bits. Then display num.f FIle due: 2240/f/ieee754.c will be collected at 12:30pm