XOR the two bits to find the bits that differ, then take this and AND it with it’s complement.

ANDing a bit with it’s complement will return only right most set bit.

eg.

11 = 00001011

13 = 00001101

XOR

00001011

00001101

————–

00000110

————–

Take the twos complement (eg -x)

11111010

AND these values

00000110

11111010

————-

00000010

————-