Operators: ~

Bitwise NOT operator.

Syntax

~integer‑operand

Unary bitwise complement

The operator results in a bitwise complement of a signed integer or unsigned integer operand: each 0 bit of the operand is set to 1, and each 1 bit is set to 0. The result of the operation is always an uint32 value unless the operand is 64-bit large. In this case the result of the operation is consequently uint64. For example:

var uint32 a = 0xAAAAAAAA; var int16 b = 4032; // b = 0x0FC0 var int64 c = -149613691251; // c = 0xFFFFFFDD2A543E8D var uint32 result = ~a; // result = 0x55555555 var uint32 result = ~b; // result = 0xFFFFF03F var uint64 result = ~c; // result = 0x22D5ABC172