Number Base Converter
Convert numbers between Binary, Octal, Decimal, and Hexadecimal bases
Number Base Converter
Number Base Information
Binary: Uses digits 0-1
Octal: Uses digits 0-7
Decimal: Uses digits 0-9
Hexadecimal: Uses 0-9, A-F
Complete Number Base Conversion Guide
Comprehensive guide to binary, octal, decimal, hexadecimal, and positional numeral systems
Understanding Number Bases
The Four Common Bases
- •Binary (Base-2): digits 0–1, used in all digital computers
- •Octal (Base-8): digits 0–7, used in Unix file permissions
- •Decimal (Base-10): digits 0–9, everyday human counting
- •Hexadecimal (Base-16): digits 0–9 and A–F, used in programming and colors
Positional Value System
- •Each digit's value = digit × base^position (right-to-left from 0)
- •Binary 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 11 decimal
- •Hex 1F = 1×16 + 15×1 = 31 decimal
- •Octal 17 = 1×8 + 7×1 = 15 decimal
- •Prefix conventions: 0b = binary, 0o = octal, 0x = hexadecimal
Conversion Reference Table
Dec → Binary → Hex (0–15)
- •0 = 0000 = 0x0
- •1 = 0001 = 0x1
- •2 = 0010 = 0x2
- •3 = 0011 = 0x3
- •4 = 0100 = 0x4
- •5 = 0101 = 0x5
- •6 = 0110 = 0x6
- •7 = 0111 = 0x7
- •8 = 1000 = 0x8
- •9 = 1001 = 0x9
- •10 = 1010 = 0xA
- •11 = 1011 = 0xB
- •12 = 1100 = 0xC
- •13 = 1101 = 0xD
- •14 = 1110 = 0xE
- •15 = 1111 = 0xF
Powers of 2 Reference
- •2^0 = 1
- •2^4 = 16
- •2^8 = 256
- •2^10 = 1,024 (1K)
- •2^16 = 65,536
- •2^20 = 1,048,576 (1M)
- •2^24 = 16,777,216
- •2^30 = 1,073,741,824 (1G)
- •2^32 = 4,294,967,296
- •2^64 ≈ 1.8×10^19
Hex Digit Groups
- •1 hex digit = 4 bits (nibble)
- •2 hex digits = 1 byte (8 bits)
- •4 hex digits = 2 bytes (16-bit word)
- •6 hex digits = 3 bytes (RGB color)
- •8 hex digits = 4 bytes (32-bit int)
- •16 hex digits = 8 bytes (64-bit/UUID segment)
Professional Applications
Computer Science & Programming
- •Bitwise operations use binary
- •Hex used for memory addresses
- •Color values (#RRGGBB)
- •ASCII/Unicode code points (e.g. 'A' = 0x41 = 65)
- •Bitmask flags
- •Networking (IP addresses, subnet masks)
- •Assembly language
Systems & Networking
- •IPv4 addresses: 4 octets decimal (192.168.1.1)
- •Subnet mask: /24 = 255.255.255.0 = 0xFFFFFF00
- •MAC address: 6 hex pairs (AA:BB:CC:DD:EE:FF)
- •VLAN IDs: decimal
- •Port numbers: decimal 0–65535
- •Memory address offsets: hex
Digital Electronics
- •Register values displayed in hex
- •Interrupt vectors (e.g. 0x0000–0x03FF)
- •GPIO pin masks in binary
- •I2C address: 7-bit (0x3C = 60 decimal)
- •SPI data frames
- •CRC checksums in hex
- •Firmware hex files (Intel HEX format)
Unix & File Systems
- •chmod permissions: octal (755 = rwxr-xr-x; 644 = rw-r--r--)
- •File magic numbers in hex (ELF: 0x7F454C46)
- •Inode numbers decimal
- •Disk sectors
- •Memory dump analysis
- •Core dump inspection
- •Kernel addresses in hex
Number Base Best Practices
Conversion Techniques
- •For large numbers: convert via decimal as intermediate
- •Group binary in 4 bits for easy hex reading
- •Memorize 0–15 decimal/binary/hex
- •Use prefix notation to avoid ambiguity
- •Verify with reverse conversion
- •For floating-point, understand IEEE 754 format
Common Mistakes
- •Confusing 0 (zero) and O (letter) in hex
- •Forgetting uppercase A–F in hex
- •Sign bit in two's complement
- •Overflow when using fixed bit width
- •Octal and hex look-alike (017 = 15 decimal in C, not 17)
- •Leading zeros changing interpretation in some languages
Number Base Examples
Common Conversions
- •255 decimal = 0xFF = 11111111 binary
- •256 = 0x100 = 100000000 binary
- •1,024 = 0x400 = 10000000000 binary
- •65,535 = 0xFFFF = 16 ones in binary
- •42 = 0x2A = 101010 binary
- •16 = 0x10 = 10000 binary
- •127 = 0x7F = 1111111 binary
Programming Examples
- •HTML color white: #FFFFFF = rgb(255,255,255)
- •chmod 755 = 111 101 101 binary
- •IP 192.168.0.1 = 0xC0A80001
- •Port 443 (HTTPS) = 0x1BB = 110110011 binary
- •ASCII 'Z' = 90 = 0x5A = 1011010
- •Null byte = 0x00 = 0 = 00000000
- •DEL = 0x7F = 127
Storage & Memory
- •1 KB = 1,024 bytes = 0x400
- •1 MB = 1,048,576 = 0x100000
- •1 GB = 0x40000000
- •4 GB (32-bit limit) = 0xFFFFFFFF + 1
- •RAM address example: 0xDEADBEEF
- •Stack pointer example: 0x7FFE0000
- •BIOS address: 0xFFFFFFF0
Frequently Asked Questions
Why do computers use binary?▾
Computers are built from transistors that have two reliable states: on (1) and off (0). Binary maps directly to these physical states. Higher bases would require transistors with multiple voltage levels, which are harder to build reliably and more susceptible to noise.
What is hexadecimal used for?▾
Hexadecimal (base 16) is a compact way to write binary. Every 4 binary digits (bits) = 1 hex digit, so 8-bit bytes = 2 hex digits. Hex appears everywhere in computing: memory addresses (0x7FFF), color codes (#FF5733), machine code listings, and error codes (0xDEADBEEF).
How do I convert binary to decimal?▾
Multiply each binary digit by 2 raised to its position (counting from 0 on the right), then sum all the results. For example: 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 8 + 0 + 2 + 1 = 11 decimal.
What is the difference between octal and decimal?▾
Decimal uses 10 digits (0–9) and is the standard counting system humans use. Octal uses only 8 digits (0–7) and each digit represents 3 bits. Octal was historically used in Unix file permissions (e.g., chmod 755) because it maps cleanly to 3-bit groups in binary.
How do I read a hex color code?▾
A hex color like #1A2B3C breaks into three 2-digit hex pairs: R=1A (26 decimal), G=2B (43 decimal), B=3C (60 decimal). Each pair ranges from 00 (0) to FF (255), giving 256 intensity levels per color channel and over 16 million possible colors.
Why is 1 KB equal to 1,024 bytes and not 1,000?▾
Computers work in powers of 2. The closest power of 2 to 1,000 is 2^10 = 1,024, so early computer scientists used 'kilo' to mean 1,024 rather than the SI standard of 1,000. This is why 1 KB = 1,024 bytes, 1 MB = 1,048,576 bytes, and 1 GB = 1,073,741,824 bytes.