Determine the value of a number in an ieee

Assignment Help Computer Engineering
Reference no: EM13986458

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.

Reference no: EM13986458

Questions Cloud

Determine the change in the gravitational potential energy : A 10-kg package is raised vertically from rest by an elevator at a constant acceleration of 2.5 m/s2. Determine the kinetic energy of the package at 13 s after the elevator began raising the package.
What is the labor efficiency variance for the month : What is the labor efficiency variance for the month?A.) $8,910 UB.) $12,555 FC.) $12,555 UD.) $8,640 U
The london currency markets : 6. In the london currency markets, the following quotes are available: EURUSD = 1.50 and EURCAD =1.6. in the new york currency markets, we find the CAD trading at CADUSD = 0.9. Explain how an arbitrager can exploit this situation. if the arbitrager c..
Describe the company current product or service : Describe the company's current product(s) or service(s). What are their sales in dollars? What is their share of the market
Determine the value of a number in an ieee : Write a C program that will determine the value of a number in an IEEE-like floating point format and create this directory inside the original directory that you created for Part 1. Copy all of the files from Part 1 into this directory.
Draw the payoff of alternative b as a function of the sand p : Draw the payoff of alternative B as a function of the S&P (with the S&P performance on the X-axis, and the return of the plan on the Y-axis.)
Determine the escape speed at the given distance : Determine the gravitational acceleration it produces at a distance of of 8.01 x103 m from its center. Determine the escape speed at a distance of 8.01 x103 m from its center.
Determine the machines second year depreciation under the : Wickland Company installs a manufacturing machine in its production facility at the beginning of the year at a cost of $108,000. The machine's useful life is estimated to be 4 years, or 140,000 units of product, with a $2,000 salvage value. During it..
What can be done to ensure that the exclusion is not lost : Recommend tax planning strategies and what can be done to ensure that the exclusion is not lost.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd