@Saurabh: You are right. I was supposed there were infinite 0's on the left. For 32-bit number, the MSB should also be checked in addition to LSB. Change the first line to: c=1-(N&1)-((N>>31)&1); will fix this case.
On 2010-12-22 14:44, Saurabh Koar wrote:
@Terence: I think the above fails for 0Xffffffff.Correct me if I m wrong.
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.