What is the tilde (~) in the enum definition?

~ is the unary one’s complement operator — it flips the bits of its operand.

~0 = 0xFFFFFFFF = -1

in two’s complement arithmetic, ~x == -x-1

the ~ operator can be found in pretty much any language that borrowed syntax from C, including Objective-C/C++/C#/Java/Javascript.

Leave a Comment