You have been assigned the task of writing a C function to compute.a floating-point representation of 2X. You decide that the best way to do this is to directly construct the IEEE single-precision representation of the result. When x is too small, your routine will return 0.0. When x is too large, it will return +∞. Fill in the blank portions of the code that follows to compute the correct result. Assume the function u2f returns a floating-point value having an identical bit representation as its unsigned argument.
Float fpwr2(int x)
{
/* Result exponent and fraction */
unsigned exp, frac;
unsigned u;
if (x <____________) {
/* Too small. Return 0.0 */
exp = _________;
frac = _________;
} else if (x < _______) {
/* Denormalized result */
exp = _________;
frac = _________;
} else if (x < _______) {
/* Normalized result. */
exp = _________;
frac = _________;
} else {
/* Too big. Return +∞ */
exp = _________;
frac = _________;
}
/* Pack exp and frac into ,32 bits */
u = exp << 23 | frac;
/* Return as float */
Return u2f (u);
}
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Concepts of Programming Languages (11th Edition)
Programming in C
Starting Out with Java: Early Objects (6th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Please solve the question by using MATHEMATICA, Write a function to randomly mix up the characters in a word. For example, if the input is "homework", you might output "eoomkwhr" or "wrhomoke". Your function should work on any input length, and all of the input letters must appear in the output.arrow_forwardWrite a Python function that computes the Fourier series expansion for a square wave for a given value of n. Ensure that your plot includes the expansion for n=1, 5 and 100. You should assume that h = 1, and T = 1 to simplify the task of plotting this series expansion.arrow_forwardcould you help me solve this and explain what each step does. Write a C function to calculate and return the factorial value of any positive integer as an argument. Then call this function from main() and print the results for the following input values: 2, 3,4, 5, 10, 15 What is the maximum value of an integer for which factorial can be calculated correctly on a machine using your algorithm?arrow_forward
- Solve by using C language and by using functions Write a program that uses six calls to the function rand() to generate six randominteger numbers, num1, num2, num3, num4, num5, and num6, and then print them out.num1 should be in the range 1 to 2 (inclusive), num2 should be in the range 1 to 100 (inclusive),num3 should be in the range 0 to 9, num4 should be in the range 1000 to 1112 (inclusive),num5 should be in the range -1 to 1, and num 6 should be in the range -3 to 11.arrow_forwardCAN YOU PLEASE RUN IT IN ONLINE GDB! C language. Write a program using pointers, which based on the adequate functions compute the sum, difference, dot product, or cross product of two vectors in Rn. Write a program using pointers, which based on the adequate functions, computes the sum, difference of multiplication of two matrices in Rm×n.arrow_forwardD. Implement a function that finds the last check digit using congruence; 3x₁ + 7x2 + 2x3 + x4 + 3x5 + x6 + 3x7 + xg + 5x9 + x10 + 3x11 + x12 = 0(mod10) given the first 11 digits stored in a string as input, eg: ¹99284792783'. (Do not use predefined functions or operators that perform this specific task) use "79357343104", "34553463334" and "66340534853" to test your function..arrow_forward
- Write a user-defined function in python that will accept five(5) numbers and calculate the sum, average, and product of those numbers that are less than or equal to 50 and greater than or equal to 25.arrow_forwardWrite a program to have the following function: Key in 10 integers from keyboard, and find all the common multiples of two integers 5 and 3 with aray, print them on the monitor and print the number of them. Please solve the same problem with 3 different programs. The first program is with the function(s) using pass-by-value. The second program is with function(s) using pass-by-reference. The third program is with the structure(s). An example of the result is as following. Please follow the input and output format of it. Please key in 10 different integers: 12 20 30 40 45 50 60 65 90 80 There is/are 4 common multiples of 5 and 3 all togetherarrow_forwardAssume that we have a function "double getDistance(struct point p1, struct point p2)" that calculates the euclidian distance (straight line distance) between point p1 and p2. The point structure has two floating point variables x and y. You need to write the getDistance function here?arrow_forward
- NOTE: Solve this as soon as possible, I need this urgently. (b). Write a function decimal2binary() that takes an integer value converts it to binary and returns the binary number. In main() ask for an integer from user, call decimal2binary() to convert the number to binary and display the result on screen.arrow_forwardPRogram - python Define a function named z and have it take 3 arguments: score , mu (sample mean) , sigma (standard deviation).. Return the calculated z-score. Use your z function on this data to show it works: You have a test score of 190. The test has a mean (μ) of 150 and a standard deviation (σ) of 25. Now define a function named std_error and have it take 2 arguments: sigma (standard deviation) , and n. Return the calculated standard error Use your std_error function (you can assume a sample size of 10) Print the answer rounded to the 2nd decimal place. (you can look up these formulas online) Zscore formula https://www.simplypsychology.org/z-score.html#:~:text=How%20do%20you%20calculate%20the,by%20the%20population%20standard%20deviation. Standard error formula https://toptipbio.com/standard-error-formula/ https://www.statisticshowto.com/probability-and-statistics/z-score/arrow_forwardpython this is connected to the last problem - the second part of the question is added. my attempt on this problem shows that the part b) (approaches N*NH) is not really wokring.. a) (answered) with a function “harmonic(n)” that computes the n-th harmonic number, write a function “harmonic_all(n)” that returns the number of values generated until all values are obtained as a function of the range of possible values n, then write a function “harmonic_sim(n)” that repeats “harmonic_all(n)” a total of n_sim = 100 times. (Attaching the code from the answer for a) d) Show that as n increases (e.g., with a doubling experiment), from n = 2 to n_max = 1,000, the value of “coupon_sim(n)” approaches “n * Hn”.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education