## Description

# Assignment Overview

**Â **

This assignment develops familiarity with the C programming language, the “gcc” compiler, integer bitwise operations, and floating point representation and arithmetic.

It is worth 40 points (4% of course grade) and must be completed no later than 11:59 PM on Thursday, 10/17.

# Assignment Deliverables

The deliverables for this assignment are the following files:

**Â **

**proj06.makefile **â€“ the makefile which produces **proj06** **proj06.support.c** â€“ the source code for your library module **proj06.driver.c **â€“ the source code for your driver module

Be sure to use the specified file names and to submit them for grading via the CSE handin system before the project deadline.

# Assignment Specifications

Some computer systems do not have floating point hardware:Â they have an Integer Unit, but not a Floating Point Unit.Â Thus, floating point operations on those systems must be performed using software.

- You will develop the C function listed below:

**float mult( float, float ); **

The two arguments are the single precision floating point values to be multiplied, and the return value is the product of those two values.Â The product will be as accurate as possible.

Arguments which are denormal will be processed as the value zero.

If either argument is the floating point value “not-a-number”, function “mult” will return that value.Â Otherwise, if either argument is the floating point value “infinity”, function “mult” will return that value.

Function “mult” (and any associated “helper” functions which you develop) will constitute the library module.Â The functions in that library module will not call any C library functions, and they will not use any floating point operations.Â There is one exception:Â the functions may use the assignment operation to copy a floating point value from one variable to another.

- You will develop a driver module to test your implementation of the support module. The driver module will consist of function “main” and any additional helper functions which you choose to implement.Â All output will be appropriately labeled.

**Â **

# Assignment Notes

**Â **

- Your driver module and your library module must be in separate source code files.

- Your source code must be translated by “gcc”, which is a C compiler and accepts C source statements.
- You must supply a “makefile” (named “proj06.makefile”), and that makefile must produce an executable program named “proj06”.

- Your driver module may not be written as an interactive program, where the user supplies input in response to prompts. Instead, your test cases will be included in the source code as literal constants.

- The Harris and Harris textbook contains information about IEEE floating point representation and operations (section 5.3.2).

Please note that infinity, not-a-number, zero and denormal numbers are special cases in IEEE floating point notation.

- An outline of one method for computing C = A * B is given below:

Extract sign, exponent, and fraction fields of both A and B.

Place leading bit in both significands.

Determine sign of C based on signs of A and B.

Determine exponent of C based on exponents of A and B.

Compute significand of C = significand of A * significand of B.

Normalize significand of C.

Insert sign, exponent, and fraction fields of C.

Note that this outline does not describe special cases, such as operands which are infinity, not-a-number, zero or denormal numbers.

- In order to work with a 32-bit item as both a floating point value and an integer value, you might consider using a union. For example:

**#include <stdio.h> **

**Â **

**union sp_item **

**{Â Â float frep;Â Â unsigned irep; **

**};Â int main() { **

**Â union sp_item num; **

**Â **

**Â num.frep = 1.5; **

**Â **

**Â printf( “Real: %fÂ Hex integer: %08x \n”, num.frep, num.irep ); } **

**Â **

When compiled and executed, that program produces the following:

**Â **

**Â Â Real: 1.500000Â Hex integer: 3fc00000 **

**Â **

Note that the four-byte memory location “num” can be referenced as both an object of type “float” and an object of type “unsigned int”.