Ekuation

Math

Number Base Converter

The Number Base Converter translates any number between all positional numeral systems -- binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and any arbitrary base from 2 to 36. Type a value into any base field and all others update instantly. Supports fractional numbers, negative sign-magnitude representation, and large integers via BigInt. Includes a positional notation breakdown, nibble-grouped bit view, step-by-step division/multiplication algorithm, and an optional hex color preview. Built for programmers, CS students, network engineers, and embedded systems developers.

Select which base you are entering the value in

Enter a decimal number (digits 0-9).

A second custom base to include in the output for side-by-side comparison.

Maximum fractional digits for non-terminating expansions.

Number Base Conversion Tips

Click to show tips

Try an Example

Pick a scenario to see how the calculator works, then adjust the values

ASCII Letter A

Convert the ASCII code for uppercase A (65) across all bases.

Key values: Decimal 65 · Binary 1000001 · Hex 41

Byte Maximum

The largest value a single byte can hold (255).

Key values: Decimal 255 · Binary 11111111 · Hex FF

Hex Color Code

Convert a common hex color code (deep sky blue) to other bases.

Key values: Hex 00BFFF · Decimal 49151 · Binary nibbles

Documentation

About the Number Base Converter

A number base converter translates values between different positional numeral systems. In everyday life we use base 10 (decimal), but computers operate in base 2 (binary), and programmers routinely work with base 8 (octal) and base 16 (hexadecimal). This converter handles all four standard bases and any custom base from 2 to 36.

Type a value into any base field and the other representations update instantly. Supports integers of arbitrary size (via BigInt), fractional numbers, negative values in sign-magnitude form, and programming prefixes such as 0b, 0o, and 0x.

How Positional Numeral Systems Work

Every positional system encodes a number as a sequence of digits, where each digit is multiplied by the base raised to the power of its position. The general formula is:

General Formula:

N=dn1bn1+dn2bn2++d1b1+d0b0N = d_{n-1} \cdot b^{n-1} + d_{n-2} \cdot b^{n-2} + \cdots + d_1 \cdot b^1 + d_0 \cdot b^0

where bb is the base and did_i is the digit at position ii.

For example, the decimal number 345 means 3×100+4×10+5×13 \times 100 + 4 \times 10 + 5 \times 1, which is 3×102+4×101+5×1003 \times 10^2 + 4 \times 10^1 + 5 \times 10^0. The same principle applies to every base: in binary, 1010 means 1×8+0×4+1×2+0×1=101 \times 8 + 0 \times 4 + 1 \times 2 + 0 \times 1 = 10 in decimal.

Supported Bases

Binary (Base 2)

Uses digits 0 and 1. Binary is the native language of digital electronics -- each bit represents an on/off transistor state. A group of 8 bits forms a byte (values 0-255), and 4 bits form a nibble (values 0-15, which maps exactly to one hex digit).

Octal (Base 8)

Uses digits 0-7. Each octal digit corresponds to exactly 3 binary bits. Octal is most commonly seen in Unix file permissions: chmod 755 means owner=rwx (7), group=r-x (5), others=r-x (5).

Decimal (Base 10)

The familiar base used in everyday mathematics. Uses digits 0-9. Thought to have originated from counting on ten fingers.

Hexadecimal (Base 16)

Uses digits 0-9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit maps to exactly 4 binary bits, making hex a compact and convenient representation for binary data. Hex is used for CSS color codes (#FF5733), memory addresses, MAC addresses, and cryptographic hashes.

Custom Bases (2-36)

Any integer base from 2 to 36 is supported. Bases above 10 extend the digit alphabet with uppercase letters: A=10, B=11, ..., Z=35. For example, base 36 uses the full set 0-9 and A-Z.

Conversion Algorithms

Base N to Decimal (Integer Part)

Multiply each digit by its positional weight and sum:

N=i=0n1dibiN = \sum_{i=0}^{n-1} d_i \cdot b^i

Decimal to Base N (Integer Part) -- Repeated Division

Repeatedly divide the decimal number by the target base, recording remainders:

  1. Divide the number by the target base.
  2. Record the remainder -- this is the next digit (least significant first).
  3. Replace the number with the quotient.
  4. Repeat until the quotient is zero.
  5. Read the digits in reverse order (bottom to top).

Example: 42 decimal to binary

42÷2=21  R0,21÷2=10  R1,10÷2=5  R042 \div 2 = 21\;R\,0,\quad 21 \div 2 = 10\;R\,1,\quad 10 \div 2 = 5\;R\,0
5÷2=2  R1,2÷2=1  R0,1÷2=0  R15 \div 2 = 2\;R\,1,\quad 2 \div 2 = 1\;R\,0,\quad 1 \div 2 = 0\;R\,1

Reading remainders bottom-to-top: 1010102101010_2

Fractional Part -- Repeated Multiplication

For the fractional portion, multiply by the target base and take the integer part as each digit:

  1. Multiply the fraction by the target base.
  2. The integer part of the product is the next fractional digit.
  3. Replace the fraction with the remaining fractional part.
  4. Repeat until the fraction is zero or you reach the desired precision.

Example: 0.6875 decimal to binary

0.6875×2=1.375,0.375×2=0.750.6875 \times 2 = \mathbf{1}.375,\quad 0.375 \times 2 = \mathbf{0}.75
0.75×2=1.5,0.5×2=1.00.75 \times 2 = \mathbf{1}.5,\quad 0.5 \times 2 = \mathbf{1}.0

Result: 0.101120.1011_2

Non-terminating fractions: Some decimal fractions cannot be represented exactly in another base. For example, 0.1100.1_{10} in decimal produces a repeating pattern in binary: 0.000110020.000\overline{1100}_{2}. The converter truncates such expansions to the configured precision and indicates when truncation has occurred.

Nibble Grouping (Binary-Hex Shortcut)

Since 16=2416 = 2^4, each hexadecimal digit corresponds to exactly 4 binary bits (a nibble). This means you can convert between binary and hex by simply grouping bits into sets of four, starting from the right:

1101D  1110E  1010A  1101D=DEAD16\underbrace{1101}_{D}\;\underbrace{1110}_{E}\;\underbrace{1010}_{A}\;\underbrace{1101}_{D} = \text{DEAD}_{16}

Similarly, octal uses 3-bit groups: each octal digit maps to exactly 3 binary bits.

Real-World Examples

1. CSS Color Codes -- Web Development

CSS colors are specified in hexadecimal. The color #FF5733 breaks down as: Red = FF (255), Green = 57 (87), Blue = 33 (51). In binary, the red channel is 11111111211111111_2 -- all 8 bits are set, meaning maximum intensity. Understanding hex-to-decimal conversion is essential for web developers who need to manipulate colors programmatically.

2. Unix File Permissions -- System Administration

The command chmod 755 sets file permissions using octal notation. Each octal digit represents 3 permission bits: read (4), write (2), execute (1). So 7=4+2+17 = 4+2+1 = rwx (all permissions), and 5=4+0+15 = 4+0+1 = r-x (read and execute only). In binary, 7558=1111011012755_8 = 111\,101\,101_2, and in decimal it equals 493.

3. Network Subnet Masks -- Networking

The subnet mask 255.255.255.0 in binary is 11111111.11111111.11111111.0000000011111111.11111111.11111111.00000000 -- 24 bits set to 1 followed by 8 bits of 0. This is written as /24 in CIDR notation. Converting between decimal and binary helps network engineers understand which bits belong to the network address versus the host address.

4. Memory Addresses -- Debugging

When debugging software, memory addresses are displayed in hex. A typical 64-bit address like 0x7FFEE3B4A8C0 is far more readable than its binary equivalent of 48 bits. The classic test value 0xDEADBEEF equals 3,735,928,559 in decimal and has 32 bits in binary.

5. Embedded Systems -- Register Configuration

Microcontroller registers are configured by setting individual bits. A control register value of 0xA5 in hex = 10100101210100101_2 in binary shows exactly which bits are set. Bit 7 (128), bit 5 (32), bit 2 (4), and bit 0 (1) are enabled, for a decimal value of 165.

Historical Context

Base-10 counting likely arose from humans having ten fingers. The ancient Babylonians used base 60 (sexagesimal), which is why we have 60 seconds in a minute and 360 degrees in a circle. The Mayans used base 20 (vigesimal).

Binary was formalized by Gottfried Wilhelm Leibniz in 1703, though it was already used in ancient Chinese mathematics (the I Ching). Binary became practical with Claude Shannon's 1937 insight that Boolean algebra could model electrical switching circuits, forming the theoretical foundation of digital computing.

Hexadecimal gained popularity in the 1960s with the IBM System/360, which used 8-bit bytes. Hex provided a compact two-character representation for each byte, compared to eight characters in binary or three in decimal (with values up to 255).

Common Misconceptions

"Hex letters A-F represent text characters"

In hexadecimal, A through F are numeric digits, not letters. A represents the value ten, B represents eleven, and so on through F representing fifteen. They are used because we need 16 unique single-character symbols and our standard digit set (0-9) only provides 10.

"0.1 decimal = 0.1 binary"

This is false. The fraction 0.1100.1_{10} (one-tenth) cannot be represented exactly in binary. It becomes the repeating pattern 0.000110020.000\overline{1100}_2. This is why floating-point arithmetic in computers sometimes produces surprising results like 0.1+0.2=0.300000000000000040.1 + 0.2 = 0.30000000000000004.

"Larger base numbers are bigger than smaller base numbers"

The string "10" means different values in different bases: 102=21010_2 = 2_{10}, 108=81010_8 = 8_{10}, 1016=161010_{16} = 16_{10}. The base determines the weight of each position.

Frequently Asked Questions

Why do computers use binary instead of decimal?

Electronic circuits have two stable states: high voltage (on) and low voltage (off). Binary maps perfectly to these two states, making it the most reliable and efficient representation for digital hardware. Building circuits with 10 distinct voltage levels (for decimal) would be far more complex and error-prone.

What is the relationship between hex and binary?

Since 16=2416 = 2^4, each hex digit encodes exactly 4 binary bits. This makes conversion between hex and binary trivially simple: group binary digits into sets of 4 and translate each group to its hex equivalent. For example, 1010  11112=AF161010\;1111_2 = \text{AF}_{16}.

Can this converter handle very large numbers?

Yes. The integer portion uses JavaScript BigInt internally, which supports integers of arbitrary magnitude without precision loss. The fractional portion uses standard floating-point arithmetic, which may introduce rounding for very long fractional expansions.

What does "non-terminating fraction" mean?

Some fractions that terminate in one base repeat infinitely in another. For example, 0.1100.1_{10} is a non-terminating fraction in binary (0.000110020.000\overline{1100}_2). The converter truncates such expansions at the configured precision and marks the result as truncated.

What are the prefixes 0b, 0o, and 0x?

These are programming conventions to indicate the base of a number literal: 0b for binary (e.g., 0b1010), 0o for octal (e.g., 0o755), and 0x for hexadecimal (e.g., 0xFF). The converter strips these prefixes automatically for convenience.

Why is base 36 the maximum?

Base 36 uses all 10 digits (0-9) plus all 26 letters of the Latin alphabet (A-Z), exhausting the standard single-character symbols. Bases higher than 36 would require multi-character digit symbols, which would make input and display ambiguous.


References

  • Knuth, D.E. The Art of Computer Programming, Vol. 2, §4.1. Addison-Wesley.
  • Stallings, W. Computer Organization and Architecture, 10th ed. Pearson.
  • Wikipedia. "Positional notation." https://en.wikipedia.org/wiki/Positional_notation
  • Wikipedia. "Two's complement." https://en.wikipedia.org/wiki/Two%27s_complement
  • Wikipedia. "Sexagesimal." https://en.wikipedia.org/wiki/Sexagesimal

Disclaimer

This calculator is provided for educational and informational purposes. While it uses BigInt for arbitrary-precision integer arithmetic, fractional conversions may exhibit minor rounding due to floating-point limitations. For mission-critical applications requiring exact fractional arithmetic (e.g., financial or cryptographic systems), use specialized arbitrary-precision libraries. The converter does not implement two's complement, IEEE 754 floating-point encoding, or other hardware-specific binary representations.

Specialized Calculators

Choose from 6 specialized versions of this calculator, each optimized for specific use cases and calculation methods.

Related Calculators

6 Calculators

More Math calculators

Calculator Search

Search and find calculators