c - How do I programmatically return the max of two integers without using any comparison operators and without using if, else, etc? -


how programmatically return maximum of 2 integers without using comparison operators , without using if, else, etc?

max: // put max(a,b) a

a -= b; &= (~a) >> 31; += b; 

and:

int a, b;

min: // put min(a,b) a

a -= b; &= >> 31; += b; 

from here.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -