Bitwise NOT (also written as ~) flips every bit of the value: every 0 becomes 1 and every 1 becomes 0. This is also called the one's complement of a number. The result depends on the bit width — NOT 0 for 8 bits gives 11111111 (255), for 32 bits gives 4294967295.
| Input | NOT Output |
|---|---|
| 0 | 1 |
| 1 | 0 |
One's complement (~N) flips all bits. Two's complement (~N + 1) flips all bits and adds 1 — this gives the negative of N in signed arithmetic. Modern CPUs use two's complement for signed integers, so -N in code equals ~N + 1.
Bitwise NOT (~) flips every bit: 0 becomes 1 and 1 becomes 0. For signed integers, ~N = -(N+1). For unsigned values it gives the one's complement.
In two's complement (the standard for signed integers), all bits set to 1 represents -1. NOT 0 flips all zeros to ones, which equals -1 in signed representation.
Choose the bit width that matches your hardware context: 8-bit for bytes, 16-bit for short integers, 32-bit for standard integers (most common), 64-bit for long integers.
One's complement flips all bits (~N). Two's complement flips all bits and adds 1 (~N + 1 = -N). Two's complement is used by virtually all modern hardware for signed integers.
See also: NAND Calculator, NOR Calculator, XOR Calculator, Bitwise Calculator.