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...
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- HAHAAAAAAHN HNM1000 OHNM 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 27 28 30 31 32 section . data .section .text .globl _start start: pushq $4 pushq $3 call function-A addq $16, $rsp movg %rax, %rbx movq $1, rax int $0x80 .type function-A, @function function-A: pushq rbp movq rsp, rbp. subq $8, rsp mova 16 (%rbp), rbx movg 24 (rbp), rcx movg %rbx, -8(%rbp) label-A: #variable y #variable z cmpq $1, $rcx je label-B movq -8 (&rbp), rax imulg %rbx, srax movq rax, -8 (%rbp) decq rcx jmp label-A label-B: movq -8 (Srbp), rax movq rbp, rsp popq &rbp retarrow_forwardconvert_std_units(ser): This function takes one input: ser: a Series. Takes a Series of numeric values and converts to standard units, that is, it computes the mean and standard deviation of ser, and for each s in ser, computes (s - mean)/(standard deviation) and returns the resulting series program returned Tests convert_std_units() on Series from a Gaussian with mu=10 & sigma=5. (0.0/3.0) For column: 0 3.758701 1 12.609100 2 16.768416 3 8.938544 4 4.511551 5 28.243002 6 4.529200 7 9.719007 8 7.083212 9 10.595014 dtype: float64 Your program returned: -0.9374788776407995 Expected return values: 0 -0.937479 1 0.262060 2 0.825794 3 -0.235429 4 -0.835441 5 2.381002 6 -0.833049 7 -0.129648 8 -0.486891 9 -0.010919 dtype: float64 The difference is 9.374788776407996. The Series did not match expected output. Test Failed: False != Truearrow_forwardGiven a Binary Number B, find its decimal equivalent. Example 1: Input: B = 10001000 Output: 136 Example 2: Input: B = 101100 Output: 44 Your Task: You don't need to read or print anything. Your task is to complete the function binary_to_decimal() which takes the binary number as string input parameter and returns its decimal equivalent. Expected Time Complexity: 0(K* Log(K)) where K is number of bits in binary number. Expected Space Complexity: 0(1)arrow_forward
- F = A +B'C which one of the followings is the representation of function F in terms of SOP form? F(A,B,C)= m0+m2+m3 F(A,B,C)= M0+M2+M3 F(A,B,C) = M1+M4+M5+M6+M7 F(A,B,C) = m1+m4+m5+m6+m7arrow_forwardWrite a function that prints the ASCII values of the char- acters using the following header: void printASCII(char ch1, char ch2, int numberPerLine) This function prints the ASCII values of characters between ch1 and ch2 with the specified number of characters per line. Write a test program that prints 6 ASCII values per line of characters from 'a' to 'm'.arrow_forwardComplete the function calculate, which computes and returns the value of the following sum for the given arguments, x and n. n Σ ( ² × ²¹) - ( ² × ²¹) + ( ² × ²²) + ( ³×²³) + - + (² × ²ª¹) 2n = X2³ i=1 Assume n ≥ 1. Examples: Function Call calculate (5,4) calculate (2,7) calculate (7,2) 0.6122448979591837 calculate (3,9) 22.196311537875324 Return Value 23 2.0256000000000003 140.0 [ ] 1 def calculate (x, n): return 0 # DELETE THIS LINE and start coding here. # Remember: end all of your functions with a return statement, not a print statement! 4 5 # Test cases 6 print (calculate (5, 4)) 7 print (calculate (2, 7)) 8 print (calculate (7, 2)) 9 print (calculate (3, 9))arrow_forward
- What does the function return for any positive values of x and n ? The answer should be a general formula in terms of x and n. int what_do_I_do ( int x, int n ) { if ( n = = 1 ) return x; else return x + what_do_I_do ( x, n – 1 ); } C++ be quick pleasearrow_forwardThe following function will correctly return true if its argument is an odd integer bool Isodd (int x) { return (x / 2 == 1); } True Falsearrow_forwardModify the below program that the input values representingfractions are stored with denominators that are positive integers. You cannot require the user to only enter a positive denominator value; the user should not be inconvenienced by such a restriction. For example, whilst values of 1 / -2 are acceptable inputs for a fraction, the output representation should be -1 / 2. Your solution should check the denominator input; if it is negative, swap the sign of both numerator and denominator instance variables. //Import the essential package import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction { private int n, d; public Fraction() { //Initialize the values this.n = this.d = 0; } public Fraction(int n, int d) { //Initialize the variables this.n = n; this.d = d; } //Define the getter function getNum() that returns the numerator public int getNum() {…arrow_forward
- ****************************** ********** Q4} For the following function f(x)=Sin(x) - Cos(x)+x. Write the mat lab commands to: 1.Draw the function in [-II, II]. 2.Find the zeros of this function. 3. Find the minimum value of function. 4. Find f(1/2) 5.integration the function.arrow_forwardQuestion VI: Write a program that computes and plots the spectral representation of the function 1. y(t) = (10e-10t)u(t) 2. y(t) = (10e-10t cos100t)u(t)arrow_forwardF(x.y,z)=x'y'z+x'yz+xy'z'+xy'z can you simplify this and draw the diagram of the simplified functionarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr