Hacker News new | past | comments | ask | show | jobs | submit login

Seems easy to parse for people used to working with bit sets in C. The &~ operator is actually two operators frequently used together to do a set difference(†). So it's asking whether n is different from removing all the bits of n from x. The answer is true.

†: It's so frequently used that on x86_64 there's a single instruction for that, ANDN.

Unless of course you are talking about Haskell and its semigroup combine operator and its lens update operator. In that case the expression can't type check: n has type State s a, x has type s, and n also has type s, which means s is an infinite type and fails occurs check.




Even in C bit twiddling, I'd write

  x & ~n
rather than

  x &~ n
The former is much easier to parse (at least to me). ~ is a unary operator, so it's easy to think of ~n as one thing. But &~ is two operators, which I think of as two things, not as one (even if the combination is common).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: