Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 2, Problem 2.94HW

Explanation of Solution

Function definition for "float_twice()" function:

The implementation for "float_twice()" function is given below:

//Header file

#include <stdio.h>

#include <assert.h>

//Declare the float_bits in unsigned data type

typedef unsigned float_bits;

//Function declaration for float_twice function

float_bits float_twice(float_bits f);

//Function definition for float_twice function

float_bits float_twice(float_bits f)

{

//Compute the value of sign field

unsigned signBit = f >> 31;

//Compute the value of exponent filed

unsigned exponentBit = f >> 23 & 0xFF;

//Compute the value of fraction field

unsigned fractionBit = f & 0x7FFFFF;

//Check if the value of "f" is "NaN" or not

if (exponentBit == 0xFF)

{

/* If "f" is "NaN", then return the given "f" value */

return f;

}

//If exponent is "0", then

if (exponentBit == 0)

{

/* Performs denormalized */

fractionBit <<= 1;

}

//If exponent is "0xFF - 1", then

else if (exponentBit == 0xFF - 1)

{

/* twice to infinity. In infinity case, the value of exponent is all ones and fraction is all zeros. */

exponentBit = 0xFF;

fractionBit = 0;

}

//Otherwise performs normalized

else

{

/* Here add 1 with exponent bit */

exponentBit += 1;

}

/* Return the value of 2.0 * f using the below expression. */

return signBit << 31 | exponentBit << 23 | fractionBit;

}

//Main function

int main(int argc, char **argv)

{

/* Call function "float_twice" with checking value using "assert" function */

/* For not a number that is "NaN" */

assert(float_twice(0xFFFFFFF8) == 0xFFFFFFF8);

/* For a valid number" */

assert(float_twice(0x10001234) == 0x10801234);

}

The given code is used to compute the twice of floating-point number "f" that is "2

Blurred answer
Students have asked these similar questions
Draw out an example of 3 systems using Lamport’s logical clock and explain the steps in words.
"Systems have become very powerful and sophisticated, providing quality information fordecisions that enable the firm to coordinate both internally and externally."With reference to the above statement compare the operations of any three data gatheringsystems today’s organisations use to aid decision making.
labmas Course Home XDocument courses/13810469/menu/a2c41aca-b4d9-4809-ac2e-eef29897ce04 There are three ionizable groups (weak acids and/or bases) in glutamic acid. Label them on the structure below Drag the appropriate labels to their respective targets. OOH [] CH3N CH CH2 CH2 IC HO Reset Help

Chapter 2 Solutions

Computer Systems: A Programmer's Perspective (3rd Edition)

Chapter 2.1, Problem 2.11PP Chapter 2.1, Problem 2.12PP Chapter 2.1, Problem 2.13PP Chapter 2.1, Problem 2.14PP Chapter 2.1, Problem 2.15PP Chapter 2.1, Problem 2.16PP Chapter 2.2, Problem 2.17PP Chapter 2.2, Problem 2.18PP Chapter 2.2, Problem 2.19PP Chapter 2.2, Problem 2.20PP Chapter 2.2, Problem 2.21PP Chapter 2.2, Problem 2.22PP Chapter 2.2, Problem 2.23PP Chapter 2.2, Problem 2.24PP Chapter 2.2, Problem 2.25PP Chapter 2.2, Problem 2.26PP Chapter 2.3, Problem 2.27PP Chapter 2.3, Problem 2.28PP Chapter 2.3, Problem 2.29PP Chapter 2.3, Problem 2.30PP Chapter 2.3, Problem 2.31PP Chapter 2.3, Problem 2.32PP Chapter 2.3, Problem 2.33PP Chapter 2.3, Problem 2.34PP Chapter 2.3, Problem 2.35PP Chapter 2.3, Problem 2.36PP Chapter 2.3, Problem 2.37PP Chapter 2.3, Problem 2.38PP Chapter 2.3, Problem 2.39PP Chapter 2.3, Problem 2.40PP Chapter 2.3, Problem 2.41PP Chapter 2.3, Problem 2.42PP Chapter 2.3, Problem 2.43PP Chapter 2.3, Problem 2.44PP Chapter 2.4, Problem 2.45PP Chapter 2.4, Problem 2.46PP Chapter 2.4, Problem 2.47PP Chapter 2.4, Problem 2.48PP Chapter 2.4, Problem 2.49PP Chapter 2.4, Problem 2.50PP Chapter 2.4, Problem 2.51PP Chapter 2.4, Problem 2.52PP Chapter 2.4, Problem 2.53PP Chapter 2.4, Problem 2.54PP Chapter 2, Problem 2.55HW Chapter 2, Problem 2.56HW Chapter 2, Problem 2.57HW Chapter 2, Problem 2.58HW Chapter 2, Problem 2.59HW Chapter 2, Problem 2.60HW Chapter 2, Problem 2.61HW Chapter 2, Problem 2.62HW Chapter 2, Problem 2.63HW Chapter 2, Problem 2.64HW Chapter 2, Problem 2.65HW Chapter 2, Problem 2.66HW Chapter 2, Problem 2.67HW Chapter 2, Problem 2.68HW Chapter 2, Problem 2.69HW Chapter 2, Problem 2.70HW Chapter 2, Problem 2.71HW Chapter 2, Problem 2.72HW Chapter 2, Problem 2.73HW Chapter 2, Problem 2.74HW Chapter 2, Problem 2.75HW Chapter 2, Problem 2.76HW Chapter 2, Problem 2.77HW Chapter 2, Problem 2.78HW Chapter 2, Problem 2.79HW Chapter 2, Problem 2.80HW Chapter 2, Problem 2.81HW Chapter 2, Problem 2.82HW Chapter 2, Problem 2.83HW Chapter 2, Problem 2.84HW Chapter 2, Problem 2.85HW Chapter 2, Problem 2.86HW Chapter 2, Problem 2.87HW Chapter 2, Problem 2.88HW Chapter 2, Problem 2.89HW Chapter 2, Problem 2.90HW Chapter 2, Problem 2.91HW Chapter 2, Problem 2.92HW Chapter 2, Problem 2.93HW Chapter 2, Problem 2.94HW Chapter 2, Problem 2.95HW Chapter 2, Problem 2.96HW Chapter 2, Problem 2.97HW

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
The recursion case is the part of a problem that can be solved using recursion method or algorithm. Hence, the ...

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    C++ for Engineers and Scientists
    Computer Science
    ISBN:9781133187844
    Author:Bronson, Gary J.
    Publisher:Course Technology Ptr
    Text book image
    C++ Programming: From Problem Analysis to Program...
    Computer Science
    ISBN:9781337102087
    Author:D. S. Malik
    Publisher:Cengage Learning
    Text book image
    COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
    Computer Science
    ISBN:9780357392676
    Author:FREUND, Steven
    Publisher:CENGAGE L
    Text book image
    Programming Logic & Design Comprehensive
    Computer Science
    ISBN:9781337669405
    Author:FARRELL
    Publisher:Cengage
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU; License: Standard YouTube License, CC-BY