Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

negation

Changing a number's sign; in two's complement, flip every bit and add 1.

Two's-complement negation maps x to (~x + 1) mod 2^n; the most negative value is its own negation.

Examples

  • Negating 6 (00000110) in 8 bits gives 11111010, which is −6. Negating −128 gives −128 again.

Read the full section →