Example
0000 0001 Yes0001 0001 No
Algorithm
Using a bit mask, divide
NUM
the variable in binaryIF R > 0 AND L > 0: Return FALSE
Otherwise,
NUM
becomes the one that is non-zeroIF NUM = 1: Return TRUE
Otherwise, go to Step 1
Complexity
Time ~ O(log(d))
where d
is number of binary digits