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

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 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