get right most bit - cook the code

Tuesday 3 October 2017

get right most bit

XOR=XOR & ~(XOR-1);

example :
xor=7 (0...0111) binary rep
xor-1=6(0...0110)
~(xor-1)=(11....1001)
xor&~(xor-1)=(00....0001) get the right most set bit

No comments:

Post a Comment