Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

In this assignment you will write a C program that will determine the value of a number in an IEEE-like floating point format.

Follow the Programming Guidelines.

For this assignment, do not use the pow or similar functions. All powers of two must be calculated by shifts or loops.

Part 1:

In this activity we we start writing a program that will be able to compute the value of an IEEE floating point format number.

We will be using a format with 4 exp bits and 7 frac bits.

  1. You will work in a group of two or three (at most) students
  2. If you are stuck, and no members of your group are available or able to help, ask the instructor.

This activity has been divided into 7 steps.

  1. Create a directory called ieee-activity-firstname1-fairstname2 and copy all of the files from ~muzahid/ieee-activity into that directory:
       cp ~muzahid/ieee-activity/* .
    Modify the main program so that it prints name of the group members instead of mine.
    The main program takes a single unsigned int argument and prints it value. 
    Understand what the main program and makefile do and then compile and run the program.
    Once the assignment is done, you will copy your folder to ~muzahid/ieee-activity/submission/
       cp -r ./ieee-activity-firstname1-firstname2 ~muzahid/ieee-activity/submission/ 
       chmod -R ugo+rwx ~muzahid/ieee-activity/submission/ieee-activity-firstname1-firstname2/ 
  2. Next we will define some constants that will be useful in the rest of the program.
    They should be defined at the top of ieee-4-7.h.
    The table below gives some of the constants you will need.
    name description
    EXPSHIFT The number of bits to shift the exp field to get it to the low order bits.
    EXPMASK The mask to use to isolate the exp bits after they have been shifted.
    FRACMASK The mask to use to isolate the frac bits.
    SIGNMASK The mask to use to isolate the sign bit. The position of the sign bit is unchanged.
    BIAS The value of the bias.
    Calculate the values of each of these and put them in ieee-4-7.h before going to the next step.
  3. Write a method called getExp that takes a single unsigned int as a parameter and returns an unsigned int containing the exp bits of the corresponding number as its low order bits.
    Use the constants from the above table in your program.
    The getExp function should not do any I/O.
    Test the program with the inputs from the table at the bottom of the page.
  4. Write a method called getFrac that takes a single unsigned int as a parameter and returns an unsigned int containing the frac bits of the corresponding number.
    Again, do the tests from the table.
  5. Write a method called getSign that returns +1 if the sign bit of the represented number is clear and -1 if it is set.
    Again, test with the values in the table.
  6. Write the following methods that each take a single unsigned int and returns either true (1) or false (0).
    For a given input, exactly one of these should return true, and the other should return false.
    1. int isDenormalized(unsigned x);
    2. int isNormalized(unsigned x);
    3. int isInfinity(unsigned x);
    4. int isNAN(unsigned x);
    Test these with the values from the table.
  7. Write the following methods that each return a double value.
    If the parameter is of the appropriate type, it returns the value of the parameter when the low 12 bits are interpreted as an IEEE floating point number with 4 exp bits and 7 frac bits.
    Write these without using the pow function.
    You can multiply or divide by powers of 2 in a loop.
    (Note that you cannot do this by shifting since the values are doubles, not integers.)
    1. double getValueDenormalized(unsigned x);
    2. double getValueNormalized(unsigned x);
    3. double getValueInfinity(unsigned x);
    You should test each of these as you write it by using inputs from the table below.
    Now write the function:
        double getValue(unsigned x);
    that returns the value of the appropriate function above or returns a NaN.
    You can generate a NaN by calculating 0.0/0.0, but you may have to do this with a variable, since otherwise the compiler might complain.

When you have finished the 7 steps of the activity do the following:

Step 8:

Instead of using ieee-4-7.c use ieee-4-7-new.c provided in the same folder (i.e., /home/muzahid/ieee-activity of any elk machine).

Compile by using command "make". It creates a new executable ieee-4-7-new.

Run the program with no parameters. It should create a file called tests-4-7.out.

Check that the first 7 lines of the file are correct, and execute:

wc tests-4-7.out

md5sum tests-4-7.out

and save the results.

Save the first 10 lines of tests-4-7.out in a file along with the output from running wc and md5sum above.

Include this with your source code and hand in the hard copy.

Do not print out the entire tests-4-7.out file.

Part 2:

Do not start this until you have Part 1 completely working.

Make a new directory: assign2 for this part. Create this directory inside the original directory that you created for Part 1. Copy all of the files from Part 1 into this directory.

Rename ieee-4-7-library.c, ieee-4-7.h, and ieee-4-7.c to ieee-library.c, ieee.h, and ieee.c.

Modify all of the functions you wrote so that they take 2 extra unsigned parameters at the end, the number of exp bits, and the number of frac bits.

Remove the defines from ieee.h. The functions should use these extra parameters instead of the constants.

Do not use global variables to solve this problem.

Modify the main program so that it takes 3 command line parameters instead of one.

The first parameter is the number of exp bits and the second is the number of frac bits.

The third parameter is the value to be converted.

Your program can assume that the values of the first two parameters are greater than 0 and sum to a number less than 32.

Make other modifications as needed. Replace the function createDataFile with this one.

It should create a file called tests-5-8.out.

Check that the first 7 lines of the file are correct, and execute:

wc tests-5-8.out

md5sum tests-5-8.out

and save the results.

Save the first 10 lines of tests-5-8.out in a file along with the output from running wc and md5sum above.

Include this with your source file and hand in the hard copy.

Do not print out the entire tests-5-8.out file.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91696322
  • Price:- $120

Guranteed 48 Hours Delivery, In Price:- $120

Have any Question?


Related Questions in Computer Engineering

Remember all of the following steps when showing that a

Remember all of the following steps when showing that a problem D is NPcomplete: 1. Show that D is in NP by briefly explaining how to quickly verify a solution to it. 2. Choose another problem Q that is known to be NP-ha ...

How does understanding various microsoft office

How does understanding various Microsoft Office applications enhance productivity in education, the workplace, and at home?

In 2005 team dad used a toyota truck with a system of

In 2005, Team DAD used a Toyota truck with a system of spinning lasers as its "visual" system. What advantages and or disadvantage does such a system have compared to camera-based systems?

Question sql uses relational and logical operators in the

Question SQL uses relational and logical operators in the WHERE clause to restrict the rows returned in a query. What are these operators and what datatypes can they work with?

Restaurant management database project the restaurant

Restaurant Management Database Project : The restaurant maintains the catalog for the list of food and beverage items that it provides. Apart from providing food facility at their own premises, the restaurant takes order ...

Explain that the biggest problems with adware is that it

Explain that the biggest problems with adware is that it slows down the computers its running on.

Discuss the importance of using an access control model in

Discuss the importance of using an access control model in determining how employees in an organization should gain access to resources.

You have been recently promoted to it security manager your

You have been recently promoted to IT Security Manager. Your first job is to document the older hardware and software your company is currently using in the IT department. State the strengths and weaknesses with the curr ...

Question suppose we are given a chain of n nodes as shown

Question : Suppose we are given a "chain" of n nodes as shown below. Each node i is "neighbors" with the node to its left and the node to its right (if they exist). An independent set of these nodes is a subset of the no ...

A study was conducted of long beach school district schools

A study was conducted of Long Beach School District schools regarding how many require school uniforms. In 2006, of the 296 schools questioned, 184 said they required s school uniforms. (Gentile & Imberman, 2009) Find th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As