Following the bit-level floating-point coding rules, implement the function with the following prototype:
/* Compute 2*f. If f is NaN, then return f. */
Float_bits float_twice (float_bits f);
For floating-point number f, this function computes 2.0 f. If f is NaN, your function should simply return f.
Test your function by evaluating it for all 232 values of argument f and comparing the result to what would be obtained using your machine’s floating-point operations
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
EBK COMPUTER SYSTEMS
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Electric Circuits. (11th Edition)
Database Concepts (8th Edition)
Modern Database Management
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
- Given the following pseudocode of the GCF (greatest common divisor), calculate the greatest common divisor of 190 and 34. Use a table where the columns are: X, Y, X - Y, Y - Xarrow_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_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_forward
- Defining a binary number as Program 1, write the function int binToDec(const int bin[]) to convert an eight-bit unsigned binary number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input. Defining bAnd, bin1, and bin2 as binary numbers as in Program 1 above, write the void function void binaryAnd(int bAnd[], const int bin1[], const int bin2[]) to compute bAnd as the logical AND of the two binary numbers bin1 and bin2. Do not output the binary number in the function. Test your function with interactive input. Program1 in C: #include <stdio.h>int main(){int binNum[8]; // Array to read binary numberlong dec=0,n=0; // variables used to convert binary to decimalint k=0,l=0;long binary=0;int i=1,j=0,remainder=0; //reading the binary number in to the array binNumprintf("Please Enter the first binary number with each bit seperate by at least one space : \n"); scanf("%d %d %d %d %d %d %d…arrow_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_forward
- Please help me solve this problem with kind explanations :) We are running programs on a machine where values of type int have a 32-bit two's complement representation. Values of type float use the 32-bit IEEE format, and values of type double use the 64-bit IEEE format. We generate arbitrary integer values x, y, and z, and convert them to values of type double as follow: /* Create some arbitrary values */ int x = random(); int y = random(); int z = random(); /* Convert to double */ double dx = (double) x; double dy = (double) y; double dz = (double) z; For each of the following C expressions, you are to indicate whether or not the expression always yields 1. If it always yields 1, describe the underlying mathematical principles. Otherwise, give an example of arguments that make it yield 0. Note that you cannot use an IA32 machine running GCC to test your answers, since it would use the 80-bit extended-precision representation for both float and double. A. (double)(float) x == dx B. dx…arrow_forward* نقطتان (2) Which code would you use to find the value of the function f? f(x)=sin(x) + cos (x) + tan (x) at x = π/4 sin(45)+cos(45)+tan(45) O sin(45®)+cos(45®)+sin(45®) O sin(pi/4)+cos(pi/2)+tan(pi/4) sind (45)+cosd(45)+tand (45) sin(pi/4)+cos(pi/4)+tan(pi/4) Oarrow_forwardQuestion 1 - Write a function to reverse the bits in a byte. /// Reverses the bits in a byte /// @param x- the input byte /// @return the same byte with the bits reversed uint8_t reverse_bits (uint8_t x) {arrow_forward
- convert_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_forwardWrite a function that takes two positive integers n and k as input. Find the sum:nC0 +nC1 +nC2 +nC3 + . . . +nCk.The program should consist of two user-defined functions. One function to calculate the sum of serieswhich subsequently takes the help of fact_helper() function. Do not use math.h library functions.Assume that your answer fits in a 4 byte/32-bit integer.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
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr