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
EBK COMPUTER SYSTEMS
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)
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY