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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -