You're right that yours should work too, because after the and the value can only have 1 bit set. But it only works for this particular and mask.