Hello Friends,
   Just to continue my topic i have found two other techniques from the 
internet to find biggest number of given two numbers. i have pasted one 
of them below

int x;  // we want to find the minimum of x and y
int y;
int r;  // the result goes here

r = y ^ ((x ^ y)&  -(x<  y)); // min(x, y)
r = x ^ ((x ^ y)&  -(x<  y)); // max(x, y)

i am not really getting how this code works, will spend some time in 
understanding it. the other logic with even other topics can be found at
http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
all credits goes to the author(s) of the above page, i have mailed this just 
for your info.  ;-)

Regards

anup





Reply via email to