I'm not quite sure why all this study is being put into something like this. 
Why not just use the < sign or functions like thomas pointed out? Writing 
clever code is just going to break things in the end.
On Jan 2, 2010, at 11:40 AM, Thomas Hruska wrote:

> Anup Joshi wrote:
> > 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
> 
> There is a saying, "Write code like the next person who has to maintain 
> it is a serial killer who knows where you live." That statement applies 
> to this whole thread. There are only three acceptable ways to determine 
> the biggest number of two numbers in C (in order of decreasing clarity):
> 
> int x = 1, y = 2, z;
> 
> z = MAX(x, y);
> 
> z = (x > y ? x : y);
> 
> if (x > y) z = x;
> else z = y;
> 
> Anything else will get you killed by aforementioned serial killer 
> programmer.
> 
> -- 
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
> 
> *NEW* MyTaskFocus 1.1
> Get on task. Stay on task.
> 
> http://www.CubicleSoft.com/MyTaskFocus/
> 
> 



[Non-text portions of this message have been removed]



------------------------------------

To unsubscribe, send a blank message to 
<mailto:[email protected]>.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to