Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

int isGreater ( int x , int y ) { int signx = ( x > > 3 1 ) & 1 ; int signy

int isGreater(int x, int y){
int signx =(x >>31) & 1;
int signy =(y >>31) & 1;
int sameVal = x ^ y;
int sameSign =(signx ^ signy);
int signDifference =(x +(~y +1))>>31) & 1)/*is difference between x and y pos or ned */
return (signDifference & !sameSign)|((!sameVal) & (sameSign | signDifference));
}
*isGreater - if x > y then return 1, else return 0
*Example: isGreater(4,5)=0, isGreater(5,4)=1
dont use any operations besides ! ~ & ^|+<<>>
use a maximum of 24 operations total
My function is not handling the case isGreater (-2147483648[0x80000000],-2147483648[0x80000000]) or (-2147483648[0x80000000],2147483648[0x80000000]) correctly. How could I modify it and what am I missing?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago