ESC
Number Systems Cheat Sheet

Decimal ↔ Binary

Pattern Description Example
0 0000 — Zero, all bits off Zero — all bits off
1 0001 — One One
2 0010 — Two Two
4 0100 — Power of 2 (2²) Power of 2 (2²)
8 1000 — Power of 2 (2³) Power of 2 (2³)
16 0001 0000 — Power of 2 (2⁴) Power of 2 (2⁴)
32 0010 0000 — Power of 2 (2⁵) Power of 2 (2⁵)
64 0100 0000 — Power of 2 (2⁶) Power of 2 (2⁶)
128 1000 0000 — Max value of signed byte Max value of signed byte
255 1111 1111 — Max value of unsigned byte (0xFF) Max value of unsigned byte (0xFF)

Powers of 2

Pattern Description Example
2⁰ 1 1 bit
2
4
8
2⁴ 16
2⁵ 32
2⁶ 64
2⁷ 128
2⁸ 256 1 byte combinations
2¹⁰ 1,024 1 KB
2²⁰ 1,048,576 1 MB
2³⁰ 1,073,741,824 1 GB

Hex ↔ Decimal

Pattern Description Example
0x0 0 — Zero Zero
0x1–0x9 1–9 — Same as decimal Same as decimal
0xA 10
0xB 11
0xC 12
0xD 13
0xE 14
0xF 15 — Max single hex digit Max single hex digit
0xFF 255 — Max byte Used in colors (#FFFFFF)
0x100 256
0x7F 127 — Max signed byte Max signed byte
0x80 128 — Min negative signed byte Min negative signed byte

Number Base Prefixes

Pattern Description Example
0b... Binary (base 2) 0b1010 = 10
0o... Octal (base 8) 0o12 = 10
(none) Decimal (base 10) 42
0x... Hexadecimal (base 16) 0xFF = 255
% Binary (assembly) %1010 = 10
h suffix Hex (assembly) FFh = 255
0 prefix Octal (C/C++) 012 = 10
# Hex (CSS colors) #FF5733

Bitwise Operators

Pattern Description Example
& AND — bits both 1 → 1 0b1100 & 0b1010 = 0b1000
| OR — at least one bit 1 → 1 0b1100 | 0b1010 = 0b1110
^ XOR — bits differ → 1 0b1100 ^ 0b1010 = 0b0110
~ NOT — flip all bits ~0b1010 = 0b0101
<< Left shift — multiply by 2^n 1 << 3 = 8
>> Right shift — divide by 2^n 16 >> 2 = 4

Common Hex Color Values

Pattern Description Example
#000000 Black color: #000000
#FFFFFF White background: #FFFFFF
#FF0000 Red
#00FF00 Green (lime)
#0000FF Blue
#FF6600 Orange
#808080 Gray (50%) opacity equivalent
#CCCCCC Light gray borders
#333333 Dark gray body text
rgba(r,g,b,a) Red Green Blue Alpha CSS: rgba(255,0,0,0.5)

Frequently Asked Questions

Hexadecimal (base 16) is used in programming and web development because it compactly represents binary data. Each hex digit maps to exactly 4 binary bits, so a byte (8 bits) needs only 2 hex digits (0xFF = 11111111). Web colors, memory addresses, and byte values are commonly written in hex.

Multiply each binary digit by its positional value (powers of 2) from right to left, then add the results. Example: 1011 = (1×8) + (0×4) + (1×2) + (1×1) = 11. Or use our Number Base Converter tool for instant conversion.

A bitwise operation works directly on the binary representation of numbers, processing individual bits. Common uses: checking/setting/clearing flags, fast multiplication/division by powers of 2, masking specific bits, and low-level hardware control.

Also on MoreOnlineTools