![EBK COMPUTER SYSTEMS](https://www.bartleby.com/isbn_cover_images/8220101459107/8220101459107_largeCoverImage.jpg)
Explanation of Solution
Function definition for “float_negate()” function:
The implementation for “float_negate()” 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_negate function
float_bits float_negate(float_bits f);
//Function definition for float_negate function
float_bits float_negate(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 && fractionBit != 0)
{
/* If "f" is "NaN", then return the given "f" value */
return f;
}
//Otherwise compute the value of "-f"
return (~signBit << 31) | (exponentBit << 23) | fractionBit;
}
//Main function
int main(int argc, char **argv)
{
/* Call function "float_negate" with checking value using "assert" function */
/* For not a number that is "NaN" */
assert(float_negate(0xFFFFFFF8) == 0xFFFFFFF8);
/* For a valid number" */
assert(float_negate(0x10001234) == 0x90001234);
}
The given code is used to compute the value of “-f” that is for floating-point number...
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 2 Solutions
EBK COMPUTER SYSTEMS
- 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
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)