Number Base Conversion: Converting Between Numeral Systems
Number base conversion transforms numbers from one numeral system to another. While we typically use base-10 (decimal), computers use base-2 (binary) and base-16 (hexadecimal). Other bases like octal (base-8) are also used in computing contexts. Understanding number base conversions is essential for programming, computer science, digital electronics, and understanding how computers represent data. Whether you're debugging code, working with color values, or studying computer architecture, mastering base conversions helps you work fluently with different number representations.
Examples
Number Base Conversion Example
Let's explore number base conversions with practical examples. You see a memory address 0x3F7A in a debugger. What's that in decimal? 0x means hexadecimal. 3F7A₁₆ = 3×4096 + 15×256 + 7×16 + 10×1 = 12288 + 3840 + 112 + 10 = 16,250₁₀.
Converting 200 to binary: 200 ÷ 2 = 100 r0, 100 ÷ 2 = 50 r0, 50 ÷ 2 = 25 r0, 25 ÷ 2 = 12 r1, 12 ÷ 2 = 6 r0, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1. Reading remainders backward: 11001000₂.
A web color is #4A90D9. Breaking it down: 4A = 74 (red), 90 = 144 (green), D9 = 217 (blue). That's a pleasant sky blue, RGB(74, 144, 217).
Unix permission chmod 755: 7 = 111₂ (rwx), 5 = 101₂ (r-x). So 755 means owner has read/write/execute, group and others have read/execute only.
Key insight: Hex is just compact binary. Each hex digit represents exactly 4 bits. This makes mental conversion easier once you memorize 0-F in binary.
Key properties
Decimal (Base-10): Human Standard
Decimal uses digits 0-9 and is our everyday number system. Each position represents a power of 10: 245 = 2×10² + 4×10¹ + 5×10⁰. Decimal likely evolved from counting on 10 fingers. Understanding decimal place value is fundamental.
Binary (Base-2): Computer Language
Binary uses only 0 and 1. Computers use binary because transistors have two states (on/off). Each position represents a power of 2: 1011₂ = 1×8 + 0×4 + 1×2 + 1×1 = 11₁₀. Understanding binary is essential for computing.
Hexadecimal (Base-16): Compact Binary
Hexadecimal uses 0-9 and A-F (A=10, B=11, ..., F=15). It's a compact way to represent binary—each hex digit equals 4 binary digits. FF₁₆ = 11111111₂ = 255₁₀. Hexadecimal is used for colors, memory addresses, and machine code.
Octal (Base-8): Historical Computing
Octal uses digits 0-7. Each octal digit equals 3 binary digits. It was common in older computers. Unix file permissions use octal (chmod 755). Understanding octal helps with Unix/Linux system administration.
Place Value: Powers of the Base
In any base, each position represents a power of that base. In base-N, positions from right are: N⁰, N¹, N², N³, ... Understanding place value in any base allows converting to/from decimal.
Arbitrary Bases
Any integer ≥2 can be a base. Base-60 (Babylonian) gives us 60 minutes/hour. Base-12 (duodecimal) is used in some measurements (dozen, gross). Understanding arbitrary bases broadens mathematical perspective.
Formulas
Any Base to Decimal
decimal = Σ(digit × base^position)
Multiply each digit by its place value and sum. 1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8+0+2+1 = 11.
Decimal to Any Base
Repeatedly divide by base, collect remainders
25 to binary: 25÷2=12 r1, 12÷2=6 r0, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1. Read remainders backward: 11001₂.
Binary to Hex
Group 4 binary digits = 1 hex digit
11010110₂ → 1101 0110 → D6₁₆. Each group of 4 bits becomes one hex digit.
Hex to Binary
1 hex digit = 4 binary digits
A3₁₆ → A=1010, 3=0011 → 10100011₂. Expand each hex digit to 4 bits.
Number Base Conversions in Computing
Number base conversions are essential in computing: binary for understanding computer operations, hexadecimal for memory addresses and color codes (#FF0000 = red), octal for Unix file permissions, debugging machine code and assembly language, network addressing (IPv6 uses hex), and cryptography. Understanding base conversions helps programmers, system administrators, and anyone working with digital technology at a low level.
Frequently asked questions
Which number bases are supported?
Binary (2), octal (8), decimal (10), hexadecimal (16), and any arbitrary base from 2 to 36.
How do I convert decimal to binary?
Divide repeatedly by 2, collect remainders, read backward. Or enter the number and we convert instantly.
How do I convert binary to decimal?
Multiply each bit by its place value (powers of 2) and sum. 1101 = 8+4+0+1 = 13.
What do letters A-F mean in hex?
A=10, B=11, C=12, D=13, E=14, F=15. Hexadecimal needs 16 symbols, so letters extend beyond 9.
How does hex relate to binary?
One hex digit = 4 binary digits. F = 1111, 0 = 0000. This makes hex a compact binary notation.
What is octal used for?
Unix/Linux file permissions (chmod 755), some older computer systems, and as compact binary (1 octal = 3 bits).
How do I convert hex colors?
#FF5733 = RGB(255, 87, 51). Each pair of hex digits is a color component. We decode color values.
What bases can I convert between?
Any base from 2 to 36. Beyond 36, we run out of single alphanumeric characters for digits.
How do I represent negative numbers?
Computers use two's complement for signed integers. We can show both unsigned and signed interpretations.
What about floating-point numbers?
Fractional conversions are supported. Binary fractions (like 0.1₂ = 0.5₁₀) follow the same place-value logic.
Why is hex common in programming?
It's compact (2 hex digits = 1 byte), easy to convert to/from binary, and readable for memory/color values.
Can I do arithmetic in other bases?
We focus on conversion. For arithmetic, convert to decimal, calculate, and convert back.
What's the binary of a large number?
Enter any decimal and we show binary, hex, and octal. Large numbers may be many digits long.
How do I convert between hex and octal?
Convert through binary: hex→binary→group by 3→octal. We handle this automatically.
Can I copy results to clipboard?
Yes—copy converted values in any format for use in your code or calculations.