Explanation of Solution
Function definition for compute the high product of signed and unsigned number:
The implementation for “signed_high_prod()” function and “unsigned_high_prod()” function is given below:
//Header file
#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
//Function definition for signed high product
int signed_high_prod(int x, int y)
{
//Compute the product of "x" and "y"
int64_t prod = (int64_t) x * y;
/* Returns result after performing right shift operation */
return prod >> 32;
}
//Function definition for unsigned high product
unsigned unsigned_high_prod(unsigned x, unsigned y)
{
//Declare and assign value for sign "x"
int sx = x >> 31;
//Declare and assign value for sign "y"
int sy = y >> 31;
/* Call signed_high_prod function to compute the signed product of "x" and "y" */
int sProduct = signed_high_prod(x, y);
//Returns the final result
return sProduct + x * sy + y * sx;
}
/* Function definition for theoretical method to compute the unsigned high product */
unsigned alternative_unsigned_high_prod(unsigned x, unsigned y)
{
//Compute the product of "x" and "y"
uint64_t prod = (uint64_t) x * y;
/* Returns result after performing right shift operation */
return prod >> 32;
}
//Main function
int main(int argc, char* argv[])
{
/* Define the value of "x" and "y" in unsigned data type */
unsigned xValue = 0x24680084;
unsigned yValue = 0xFFFFFFFF;
/* Call function with checking value using "assert" function */
assert(alternative_unsigned_high_prod(xValue, yValue) == unsigned_high_prod(xValue, yValue));
return 0;
}
The given code is used to compute the high product of “x” and “y” for signed and unsigned number...
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
- The latest super-duper supercomputer has memory locations that are 64-bits wide. What is the largest unsigned integer that can be stored in one memory location? Suppose that we use sign-magnitude for storing negative numbers and dedicate one bit for a sign bit. What would be the largest POSITIVE integer that can be stored in a memory location.arrow_forwardThis question concerns the field GF(256). The modulus is P(x) = x° + x* + x° + x + 1. Please answer the following questions about arithmetic in this field. a) If p(x) = x° + x* + x, what is the corresponding hexadecimal representation? Please prepend an "Ox" on your answer and use lowercase letters (if letters occur). b) If p(x) = x' + x + x² + 1, what is the corresponding hexadecimal representation? Please prepend an "Ox" on your answer and use lowercase letters (if letters occur). c) Consider the hex byte Ox8b. What is the corresponding element of GF(256) (as a polynomial)? d) Consider the hex byte 0x2d. VWhat is the corresponding element of GF(256) (as a polynomial)?arrow_forwardThe function that is not implemented by the karnaugh map shown below is XYI WZ 00 01 11 10 00 X 01 X 1 11 1 1 1 1 10 X X Select one: O a. (W + Y) X O b. None of the above O c. XY + YW O d. (W + X)(W + Y)(X + Y)arrow_forward
- A Gray code is a sequence of binary numbers with the property that no more than 1 bit changes in going from one element of the sequence to another. For example, here is a 3-bit binary Gray code: 000, 001, 011, 010, 110, 111, 101, and 100. Using three D flip-flops and a PLA, construct a 3-bit Gray code counter that has two inputs: reset, which sets the counter to 000, and inc, which makes the counter go to the next value in the sequence. Note that the code is cyclic, so that the value after 100 in the sequence is 000.arrow_forwardWhen multiplying an elliptic curve point P by a positive integer n, it can be done in O(log n) time by doubling an accumulator and adding P according to the bit pattern of n. For example, 6P can be expressed as ((0*2+P)*2+P)*2. In the format shown above, show the sequence of doubles and adds, from left to right, needed to compute 11P. 11 in binary is 1011. Autograder format: Begin with 0*2. After each +P close a parentheses (don't forget the opening parentheses) and after each *2 do not insert a close parentheses. Because of the order of operations these are the only parentheses needed. Do not insert any other parentheses or any spaces. Hint: there should be exactly three close parentheses.arrow_forwardImplement the following Boolean function F(A, B, C, D)= m(1,4, 6, 7, 8,9, 12, 13,15) with: An 8x1 MUX. Assume that the inputs A, B, and C are used for the select lines.arrow_forward
- If F(x, y, z) = (xy+z'), what is the complement of F? You need to simplify it.arrow_forwardGive regular expressions for the i (a) {w : w contains at most two 1s} (b) {w : w contains at least two 1s} (c) {w: every odd position in w is 1} (d) {w : w contains an even number of 0s, orarrow_forwardSimplify the function F represented by the following Kmap into 4 terms 9 literals SOP expression: AB 00 01 11 10 CD 00 01 1 1 11 1 10 1 1. 1. 1. 1. 1. 8.arrow_forward
- نقطة واحدة Unstable systems usually exhibit erratic and extreme behavior and cause overflow in any practical. True O False O نقطة واحدة A discrete-time signal is an indexed sequence of real or complex numbers. Thus, a discrete-time signal is a function of an integer-valued variable, n, that is denoted by x(n). Although the independent variable n need not necessarily represent "time" (n may, for example, correspond to a spatial coordinate or distance), x(n) is generally referred to as a function of time. True O False Oarrow_forwardDuality Principle can be : * O X(XY) = XY + XX O X(XY) = X + XY O X(XY) = YX + Y O ALL ARE WRONGarrow_forwardQ2. Given, F(w,x,y,z) = II M(0,4,8,12) ; (here M means Maxterms) a) Complete the truth table for F W X F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 b) Write the minimum expression of Farrow_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