@Abhishek: int c = (a - b) >> 31; max = c & b | ~c & a;
Explanation: c = 0 if a >= b, else c = all one bits. Then c & b = 0 if c = 0, but c & b = b if c = all ones, i.e. if the max is b, and ~c & a = a if c = 0, i.e., if the max is a, but ~c & a = 0 if c = all ones. Dave On Aug 23, 8:07 am, Abhishek Yadav <algowithabhis...@gmail.com> wrote: > Write a method which finds the maximum of two numbers You should not > use if-else > or any other comparison operator. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.