Base Converter

Convert numbers between different bases (binary, octal, decimal, hexadecimal, and any base from 2 to 36).

Result (decimal)
10
Input (binary)
1010
Decimal equivalent
10
Result (decimal)
10
Character count
2 digits

Conversion to decimal

(1010)_2 =
1 × 2^3 + 0 × 2^2 + 1 × 2^1 + 0 × 2^0
= 10

What is a number base?

A number base (also called radix) defines how many unique digits are used to represent numbers in a positional numeral system. In our everyday decimal system, we use base 10, which means we have 10 unique digits: 0 through 9. When we count past 9, we carry over to the next position and write "10."

Different bases work the same way but with different numbers of available digits. Binary (base 2) uses only 0 and 1. Octal (base 8) uses 0 through 7. Hexadecimal (base 16) uses 0 through 9 plus letters A through F to represent values 10 through 15.

The concept of positional notation means each digit's value depends on its position. In decimal, the number 253 represents 2×100 + 5×10 + 3×1, or equivalently 2×10² + 5×10¹ + 3×10⁰. The same principle applies to any base—you just replace 10 with the appropriate base value.

Common number bases and their uses

Binary (base 2)

Binary is the foundation of all digital computing. Computers use binary because electronic circuits have two stable states: on and off, represented as 1 and 0. Every piece of digital information—from text and images to videos and software—ultimately exists as sequences of binary digits (bits).

A single binary digit is called a bit. Eight bits form a byte, which can represent values from 0 to 255 (or 00000000 to 11111111 in binary). Memory sizes, file sizes, and data transfer rates are all measured in bytes and their multiples.

Octal (base 8)

Octal was historically popular in computing because it provides a compact way to represent binary data. Each octal digit corresponds exactly to three binary digits, making conversions straightforward. For example, the binary number 101110 can be split into groups of three (101 and 110), which convert to octal 56.

Today, octal appears primarily in Unix/Linux file permissions. When you see permission codes like 755 or 644, each digit represents read, write, and execute permissions for owner, group, and others respectively.

Decimal (base 10)

Decimal is the standard system for human counting and arithmetic, likely because humans have ten fingers. Nearly all everyday calculations, financial transactions, and measurements use decimal notation.

In computing, decimal is used for user-facing displays but converted to binary for internal processing. This conversion can sometimes cause precision issues with floating-point numbers, which is why financial software often uses specialized decimal arithmetic libraries.

Hexadecimal (base 16)

Hexadecimal is essential in modern computing and programming. Each hex digit represents exactly four binary digits, making it perfect for expressing byte values compactly. A single byte (8 bits) becomes just two hex digits instead of eight binary digits.

Common uses for hexadecimal include:

  • Color codes: Web colors like #FF5733 use hex values for red, green, and blue components
  • Memory addresses: Programmers and debuggers display memory locations in hex
  • MAC addresses: Network hardware identifiers use hex (e.g., 00:1A:2B:3C:4D:5E)
  • Unicode: Character codes are often written in hex (e.g., U+00E9 for é)
  • Assembly language: Low-level programming frequently uses hex for readability

How base conversion works

Converting to decimal

To convert any number to decimal, multiply each digit by its positional value and sum the results. The positional value is the base raised to the power of the position, counting from 0 on the right.

For example, converting binary 1101 to decimal:

11012=1×23+1×22+0×21+1×20=1×8+1×4+0×2+1×1=8+4+0+1=1310\begin{aligned} 1101_2 &= 1 \times 2^3 + 1 \times 2^2 + 0 \times 2^1 + 1 \times 2^0 \\ &= 1 \times 8 + 1 \times 4 + 0 \times 2 + 1 \times 1 \\ &= 8 + 4 + 0 + 1 \\ &= 13_{10} \end{aligned}

Converting hexadecimal 2F to decimal:

2F16=2×161+15×160=2×16+15×1=32+15=4710\begin{aligned} 2F_{16} &= 2 \times 16^1 + 15 \times 16^0 \\ &= 2 \times 16 + 15 \times 1 \\ &= 32 + 15 \\ &= 47_{10} \end{aligned}

Converting from decimal

To convert from decimal to another base, repeatedly divide by the target base and collect the remainders. The remainders, read from last to first, form the converted number.

Converting decimal 47 to binary:

DivisionQuotientRemainder
47 ÷ 2231
23 ÷ 2111
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading remainders from bottom to top: 47₁₀ = 101111₂

Direct conversion between bases

When converting between bases that are powers of each other, you can use shortcuts. Binary and hexadecimal have a 4:1 relationship (2⁴ = 16), so each hex digit equals exactly four binary digits.

Binary to hex example: 11010110₂

  1. Group into fours from right: 1101 0110
  2. Convert each group: D 6
  3. Result: D6₁₆

Binary to octal works similarly with groups of three (2³ = 8).

Extended bases (base 2 to 36)

Bases beyond 16 use letters beyond F. Base 36 is the maximum commonly used because it employs all 10 digits (0-9) plus all 26 letters (A-Z), giving exactly 36 symbols.

Base 36 is sometimes called "alphanumeric base" and appears in:

  • URL shorteners: Services compress long IDs into short alphanumeric strings
  • Product codes: Some inventory systems use base 36 for compact serial numbers
  • YouTube video IDs: The 11-character IDs use a base-64 variant

Higher bases require additional symbols beyond the standard alphanumeric set, which creates compatibility issues and reduces readability.

Practical applications

Programming and software development

Programmers constantly work with different bases:

  • Bit flags: Binary is used to represent sets of boolean options compactly
  • Byte manipulation: Hex makes it easy to see individual bytes in data
  • Bitwise operations: AND, OR, XOR, and shifts are clearer in binary
  • Debugging: Memory dumps and network packet captures display hex

Digital electronics

Hardware engineers design circuits using binary logic. Understanding base conversion helps when:

  • Designing digital circuits with logic gates
  • Analyzing signal patterns on oscilloscopes
  • Programming microcontrollers and embedded systems
  • Working with ADC/DAC converters

Networking and security

Network protocols heavily use hexadecimal:

  • IPv6 addresses: Written as eight groups of hex digits (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334)
  • SSL certificates: Fingerprints displayed in hex
  • Cryptographic hashes: SHA-256 and MD5 produce hex output
  • Packet analysis: Tools like Wireshark show data in hex

Data compression and encoding

Base conversion principles underlie many encoding schemes:

  • Base64: Uses 64 characters to encode binary data as text (common in email and web)
  • Base58: Bitcoin addresses use this to avoid confusing characters like 0/O and l/1
  • Base32: Used in two-factor authentication codes (TOTP)

Common conversion reference

DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
321000004020
64100000010040
1281000000020080
25511111111377FF
256100000000400100

Tips for mental conversion

Binary to decimal shortcuts

  • Powers of 2 create recognizable patterns: 1, 2, 4, 8, 16, 32, 64, 128, 256...
  • Memorize key values: 1111₂ = 15, 11111₂ = 31, 111111₂ = 63
  • Adding a 1 on the right doubles the value plus 1

Hex to decimal shortcuts

  • Single hex digits A through F equal 10 through 15
  • Two hex digits: first digit × 16 + second digit
  • FF = 255 (maximum byte value)
  • 100 hex = 256 decimal

Recognizing patterns

  • All 1s in binary equals one less than the next power of 2 (e.g., 1111 = 15 = 16-1)
  • Powers of 2 in hex always have one non-zero digit (10, 20, 40, 80, 100, 200...)
  • Octal digits 0-7 convert directly to 3-bit binary groups

Limitations and considerations

This calculator handles integer conversions for arbitrary precision using BigInt, which means it can convert very large numbers accurately. However, there are some considerations:

  1. Fractional numbers: This calculator handles integers only. Converting fractional parts requires different algorithms and may result in repeating sequences.

  2. Negative numbers: The calculator works with positive integers. Negative numbers in computing use representations like two's complement, which this calculator doesn't address.

  3. Leading zeros: The output omits leading zeros. If you need a specific number of digits (like for byte representation), you may need to pad the result.

  4. Case sensitivity: The calculator accepts both uppercase and lowercase letters for bases above 10. Results are displayed in uppercase for consistency.