Number bases: understanding binary, octal, and hexadecimal
We count in decimal (base 10) because we have ten fingers, but computers think in binary (base 2): ones and zeros. Hexadecimal (base 16) bridges both worlds—it compresses binary into a more readable form. A single hex digit represents four binary bits, making hex ideal for memory addresses, color codes (#FF5733), Unicode escapes (), and API responses. Octal (base 8) is less common today but appears in Unix file permissions (755 means rwx for owner, r-x for group, r-x for others). Understanding number bases is essential for systems programming, low-level debugging, network protocols, and reading technical documentation where values are often expressed in different bases.
This tool converts any number between decimal, binary, octal, and hexadecimal instantly. Enter a value in any base, and watch all other bases update live. No mental math required. Whether you're decoding a memory dump, setting file permissions, understanding color values, or reading API documentation, this converter demystifies number base conversions in seconds.
Understanding different number bases
- Decimal (Base 10): Everyday numbers using digits 0–9. The default for most software and human interaction.
- Binary (Base 2): Only 0 and 1. The native language of computers—a single bit is one switch state. Eight bits make a byte. Used in hardware, low-level programming, and bitwise operations.
- Octal (Base 8): Digits 0–7. Historically used in Unix permissions (e.g., 755) and older systems. Less common today but still relevant in legacy code.
- Hexadecimal (Base 16): Digits 0–9, letters A–F (A=10, B=11, ... F=15). Compact representation of binary data. Used in color codes, memory addresses, Unicode, and API responses.
- Prefix conventions: Prefixes clarify the base: 0b (binary), 0o (octal), 0x (hex), or decimal (no prefix). Example: 0xFF is hex 255, 0b11111111 is binary 255, 0377 is octal 255.
Common base conversion scenarios
- Bitwise operations. When debugging bit flags or applying masks, convert to binary to visualize which bits are set.
- File permissions. Unix permissions like 755 are octal: 7 (rwx) for owner, 5 (r-x) for group, 5 (r-x) for others. Convert to understand or set permissions.
- Memory and debugging. Memory dumps and debuggers show addresses in hex. Convert to decimal for calculations or vice versa.
- Color codes. Web colors use hex: #FF5733. Understanding hex helps when programmatically generating or manipulating colors.
- Unicode and escapes. Unicode code points like U+1F600 (emoji) are in hex. Protocol documentation often uses hex notation for byte sequences.
Frequently asked questions
Why use hexadecimal when binary exists?
Hex is a shorthand for binary. One hex digit = 4 binary bits. The number 0xFF is clearer and shorter than 0b11111111, while being trivial to convert. Hex balances human readability with machine representation.
How do I manually convert between bases?
To convert to decimal: multiply each digit by the base raised to its position power, then sum. To convert from decimal: repeatedly divide by the target base and collect remainders in reverse. Example: 10 decimal = 1010 binary (10÷2=5 rem 0, 5÷2=2 rem 1, 2÷2=1 rem 0, 1÷2=0 rem 1).
What's the largest number I can convert?
Theoretically unlimited, but practical limits depend on your system and the tool. Most programming languages handle at least 32-bit or 64-bit integers natively. For very large numbers, use specialized math libraries.
How do I remember which letters represent which hex digits?
Hex uses A=10, B=11, C=12, D=13, E=14, F=15 simply as extensions of 0–9. Think of A–F as "10 through 15" and it becomes intuitive with practice. The quick reference table below helps.