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

  Why both support pass-by-reference and pass-by-value

For primitive data types, C# implements pass-by-value as the default.although , VB6.0 implements the pass-by-reference as the default. They both support pass-by-reference and pass-by-value.

  Research and write a short description of internet

research and write a short description of internet technologies 3-4 pages not including cover page or reference list

  Demorgans theorem

Compute by means of the truth table the validity of DeMorgan’s theorem for three variables: (ABC)’ = A’ + B’ + C’. Simplify the following expressions using Boolean algebra. AB + A(CD + CD’)

  Prepare an isr and startup code for a system

Prepare an ISR and startup code for a system that lights up LED0 on the PSoC Eval1 board (suppose that a wire is connecting P1[0]) to indicate "Low Voltage" whenever there is a supply voltage monitor interrupt.

  Describe the difficulty of it project execution and support

discuss the difficulty of it project execution and support why executing a plan can be difficult. describe one or two 1

  Sums each component of the pairs

Write a version of sumPairs of Ex. 3.1.8 that sums each component of the pairs discretely, returning a pair consisting of the sum of the first components and the sum of the second components. So essentially [(3,1)(10,3)] would return (13,4).

  Write a program that reads a file containing two columns

write a program that reads a file containing two columns of floating point numbers. prompt the user for the file name. print the average of each column in java.

  How to write code for selection sort, insertion sort

How to write code for selection sort, insertion sort. Using your performance of selection, bubble and insertion sort, add a counter in an appropriate place so as to measure the runtime of your code for example this capacity be a counter to track ..

  Program is internet based and it is expected to boost sale

Sunnyville Inc. is in the business of selling home appliances. Sunnyville Inc. has over 50 sales agents all over the country. The management at Sunnyville Inc. has decided to implement an online sales program. The new sales program is Internet bas..

  Ftp client without using any library you must create a

ftp client without using any library. you should create a seperate a socket program and then use that instead of

  Advantage and one disadvantage of virtual machine approach

Java and many other programming languages have taken approach of executing on a virtual machine, as opposed to compiling to native machine code.

  New eap authentication

When a new EAP authentication is added, software do NOT have to be altered on the: No software has to be changed on ANY device, Authenticator, Central authentication server, Client.

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