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
Computer Systems: Program... -Access
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting out with Visual C# (4th Edition)
Concepts of Programming Languages (11th Edition)
Problem Solving with C++ (10th Edition)
Database Concepts (7th Edition)
Modern Database Management (12th Edition)
- I want to write C or C++ functions that evaluate to ONE when the given conditions are true, and to ZERO when they are false. The following are the fourt conditions: int a(int x); //Any bit of x equals 0. int b(int x); // Any bit of x equals 1. int c(int x); //Any bit in the LSB of x equals 0. int d(int x); //Any bit in the MSB of x equals 1. The code should follow the bit-level integer coding rules, with the additional restriction that you may not use equality (==) or inequality (!=) tests.arrow_forwardSo this is a function that prints the two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers. (The output can be greater than a 32 bit integer.) I want detailed explanation on the part of the code that is in bold and underlined in the starting of the function (long sum = *arr; int min = *arr; int max = *arr;). I cant understand the purpose and the logic behind this specific initialization. Sample Input 1 2 3 4 5 Sample Output 10 14 The actual code- void miniMaxSum(int arr_count, int* arr) { long sum = *arr; int min = *arr; int max = *arr; for(int i = 1; i < arr_count; i++){ sum = sum + arr[i]; if(arr[i] > max){ max = arr[i]; } if(arr[i] < min){ min = arr[i]; } } printf("%ld %ld", sum - max, sum - min); }arrow_forwardIf you implement the function F(A,B,C,D)= Sum m (3,4,6,11,12,13,14) using a 8-1 MUX then which of the input position will be equal to D : a. I1 & I6 b. only I5 c. I2 & I6 & I7 d. Only I7 e. None of the choices f. I1 & I5arrow_forward
- Please use C++ In this lab, you need to write a program which, given a seven digit binary input given below, it will check to see if there is a single bit error using the Hamming Code method discussed in lab. For a sample of Hamming Code, the input: 1110101 will reveal that ‘110’ is the location of the error (meaning the sixth slot in the input), so the corrected number would be 1010101, and the actual message transmitted, would be 1011, which is 11 in decimal. You can use this example to test your program to ensure it’s working correctly. Create a program which can, given a 7-bit long input, written in Hamming Code style, do the three following tasks, displaying the results as output. (1) Determine if there’s an incorrect bit, and if so, where it is. (2) Display what the CORRECT code should look like (if it needs to be corrected.) (3) Display the decimal form of the message that was sent, after any needed correction. Remember, when using Hamming…arrow_forwardBELOW MCQ GIVEN ANSWER CAN BE MORE THAN ONE OPTION. PLEASE PROVIDE CORRECT ANSWERS. ------------------- Q3 :- The ANSI C function below causes the program in which it runs to malfunction . Which of the following connection will help to perform function successfully ? /* Return a count of all the bits set in bytes */ int bitcount (unsigned char c) { unsigned char x , b , count =0; for (b = 0 , x= 1 ; !(x & 0x100); ++b, x <<=1) { if (x | c ) ++count; } return count; } A) change the type of x to a type larger than unsigned char. B) remove the extraneous variable b. C) change the return type to unsigned char . D) change if ( x | c) to if ( x & c) inside the for loop. E) change ! (c & 0x100) to ( x < 0x100) inside the for loop.arrow_forwardinside the cpu, mathematical oprations like addition subtraction ,multipulcation and division are done in bit-livel. To perform bit-livel opration in c programming ,bitwise operators are used. apply the knowledge you gained while learing bit wise operators. write a program to input two integers from user by using single scanf.computer and display the value for a and b, a|b,a theta b.arrow_forward
- Suppose A = -14 and B = +6 (both in base 10) C=A*B What is the resulting product of your previous multiplication in FP decimal representation (simply use a decimal point)? Take the result you just produce and shift it by three digits to the right of the decimal point (e.g., if your number was 12.0 it now becomes 0.012). Now, express your shifted result as a single precision FP number using the IEEE 754 standard for single precision (of course you need to convert the number from decimal to binary). Please do not calculate more than the first 8 fraction bits.arrow_forwardIf you implement the function F(A,B,C)= Sum m (2,4,6,7) using a 2-1 MUX then the input position I0 will be: a. None of the choices b. I0 = AB' c. I0 = C' d. I0 = BC' e. I0 = AC f. I0 = 1arrow_forwardNumbers can be regarded as product of its factors. For example,8 = 2 x 2 x 2; = 2 x 4.Write a function that takes an integer nand return all possible combinations of its factors.Note:You may assume that n is always positive.Factors should be greater than 1 and less than n.Examples:input: 1output:[]input: 37output:[]input: 12output:[ [2, 6], [2, 2, 3], [3, 4]]input: 32output:[ [2, 16], [2, 2, 8], [2, 2, 2, 4], [2, 2, 2, 2, 2], [2, 4, 4], [4, 8]].arrow_forward
- Suppose we number the bytes in a w-bit word from 0 (least significant) to w/8 – 1 (most significant). Write code for the following C function, which will return an unsigned value in which byte i of argument x has been replaced by byte b: unsigned replace_byte (unsigned x, int i, unsigned char b); Here are some examples showing how the function should work: replace_byte(0x12345678, 2, 0xAB) --> 0x12AB5678 replace_byte(0x12345678, 0, 0xAB) --> 0x123456AB Bit-Level Integer Coding Rules In several of the following problems, we will artificially restrict what programming constructs you can use to help you gain a better understanding of the bit-level, logic, and arithmetic operations of C. In answering these problems, your code must follow these rules: Allowed operations All bit-level and logic operations. Left and right shifts, but only with shift amounts between 0 and w – 1. Addition and subtraction. Equality (==) and inequality (!=) tests. (Some of the problems do not allow…arrow_forwardIn a given 32-bit floating-point representation of numbers, if the number of bits of the mantissa is reduced to accommodate an increase in the number of bits of the exponent, this will result in the following: (select the best answer) Increased range of the numbers at the expense of the precision Increased precision of the numbers at the expense of the range Both range and precision increase Both range and precision decreasearrow_forwardGiven an integer N and an integer D, rotate the binary representation of the integer N by D digits to the left as well as right and print the results in decimal values after each of the rotation. Note: Integer N is stored using 16 bits. i.e. 12 will be stored as 0000.....001100. Example 1: Input: N = 28, D = 2 Output: 112 7 Explanation: 28 in Binary is: 000...011100 Rotating left by 2 positions, it becomes 00...1110000 = 112 (in decimal). Rotating right by 2 positarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education