Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal
About this tool
The Number Base Converter translates integers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). These four numeral systems cover the vast majority of computing use cases โ from low-level bit manipulation to memory addresses, file permissions, and color codes.
When to use it
- โConverting hex color values (#a855f7) to RGB decimal components
- โUnderstanding binary representations when working with bitwise operations
- โConverting Unix file permission octals (755, 644) to understand what they mean
- โWorking with memory addresses and CPU registers in systems programming
Tips
- โHex digits A-F represent decimal 10-15. One hex digit = 4 binary bits (a nibble).
- โBinary inputs can use spaces for readability (1010 1111) โ spaces are ignored during conversion.
Frequently asked questions
Why do computers use binary instead of decimal?
Computer hardware is built from transistors that are either on (1) or off (0). Binary maps directly to this two-state physical reality. Decimal would require 10 distinct voltage levels per digit โ far more complex and error-prone to build reliably at the scale of billions of transistors.
What is hexadecimal primarily used for in programming?
Hex is a compact representation of binary โ each hex digit maps exactly to 4 bits. It appears in: memory addresses (0x7ffe8a3b), color codes (#ff5500), byte values in networking (MAC addresses, IP packets), and bitmask constants. It bridges the gap between the unreadable binary and the less-compact decimal.
How do I mentally convert binary to hex without calculating?
Group binary digits in sets of 4 from the right: 1010 1111 = AF in hex. Each group of 4 bits maps to one hex digit: 0000=0, 0001=1, ..., 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F. Memorizing these 16 mappings makes binary-to-hex conversion instant.
How does 2's complement affect negative numbers in binary?
Computers represent negative integers using 2's complement: flip all bits of the positive number, then add 1. For an 8-bit integer, -1 is 11111111 and -128 is 10000000. This system makes addition hardware work for both positive and negative numbers without special cases. This is why uint8 goes 0-255 but int8 goes -128 to 127.