Binary Converter

Switch any number between binary, octal, decimal, and hexadecimal.

Convert 4 bases BigInt
Rate this calculator

Binary ↔ Decimal ↔ Hex ↔ Octal

Four bases · unlimited precision via BigInt

Instructions — Binary Converter

1

Enter a number and pick its base

Type the value and choose its base (decimal by default). The converter outputs the other three representations instantly. Binary input takes 0s and 1s; hex takes 0-9 and A-F.

2

Use the quick picks

Preset buttons cover the common bit boundaries: 10, 16, 42, 100, 255 (max byte), 1024 (1 KB), 4096 (4 KB), 65535 (max 16-bit).

3

Read all bases at once

Binary is grouped in 4-bit nibbles, hex in 4-character chunks. Bit count is shown for any value. BigInt support means even 100+ digit numbers convert cleanly.

Byte ranges: 0-255 fits in 8 bits = 1 byte. 0-65535 = 16 bits.
Hex shorthand: 4 binary bits = 1 hex digit. 0xFF = 11111111 = 255.

Formulas

Numbers can be expressed in any positional base. Each digit is multiplied by a power of the base to give the decimal value.

Binary to Decimal
$$ N = \sum_{i=0}^{n-1} b_i \times 2^i $$
Each binary digit b_i contributes 2 to the i-th power, read from right (i=0) to left. 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 11 decimal.
Decimal to Binary
$$ b_i = \left\lfloor \frac{N}{2^i} \right\rfloor \bmod 2 $$
Divide by 2 repeatedly and read remainders bottom-up. 42 ÷ 2 = 21 r 0, 21 ÷ 2 = 10 r 1,..., gives 101010.
Binary to Hexadecimal
$$ 4\,\text{bits} = 1\,\text{hex digit} $$
Group binary bits into nibbles of 4 (from the right) and map each to a single hex character: 0000 → 0,..., 1111 → F. Direct, no decimal step.
Binary to Octal
$$ 3\,\text{bits} = 1\,\text{octal digit} $$
Group binary bits into triplets from the right. 111 = 7, 110 = 6, etc. Used for Unix file permissions (e.g., 755 = rwxr-xr-x).
Hexadecimal to Decimal
$$ N = \sum_{i=0}^{n-1} h_i \times 16^i $$
Each hex digit h_i contributes 16 to the i-th power. 0xFF = 15×16 + 15×1 = 255. 0x100 = 256.
Bit Count for a Value
$$ \text{bits} = \lceil \log_2(N+1) \rceil $$
A value N fits in ⌈log₂(N+1)⌉ bits. 255 needs 8 bits, 256 needs 9, 65,535 needs 16, 4,294,967,295 needs 32.

Reference

4-bit nibble table
BinaryOctalDecimalHex
0000000
0001111
0010222
0011333
0100444
0101555
0110666
0111777
10001088
10011199
10101210A
10111311B
11001412C
11011513D
11101614E
11111715F

Common boundaries

Bit-width limits are everywhere in computing.

Unsigned ranges
BitsMax value
4 bits (nibble)15 (0xF)
8 bits (byte)255 (0xFF)
16 bits65,535 (0xFFFF)
32 bits4,294,967,295
64 bits1.84 × 10¹⁹
Common patterns
PatternUse
0xFFMax byte / RGB red
0xFFFFMax 16-bit / port number
0xDEADBEEFDebugging marker
0x7FASCII delete
0x20ASCII space

Article — Binary Converter

Binary converter: decimal, binary, octal, and hexadecimal in one view

A binary converter switches a number between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). The four bases are interchangeable representations of the same value. 42 in decimal is 101010 in binary, 52 in octal, and 0x2A in hex — all the same number.

Binary is the native language of computers. Every byte of memory, every CPU instruction, and every network packet is a sequence of bits. Hex is the compact, human-readable form of binary because each hex digit maps to exactly 4 bits. Decimal is the form humans naturally read. Conversion between all four is a daily task in programming, networking, and digital electronics.

What a binary converter does

The converter takes a single value entered in one base and shows the equivalent representation in the other three bases. Internally it parses the input as a BigInt (so arbitrarily large numbers work) and then formats it back to each target base. The conversions are exact: there is no rounding or precision loss, because integer bases are an arithmetic property of the number itself.

Each base uses a different alphabet of digits. Binary has just 0 and 1. Octal uses 0-7. Decimal uses 0-9. Hex uses 0-9 plus A-F for the values 10-15. The converter validates input against the chosen base — entering "8" with octal selected will flag an error, since 8 is not a valid octal digit.

Did you know

Gottfried Leibniz published the first systematic description of binary arithmetic in 1703 — about 240 years before the first electronic computer. He saw it as elegant proof that all numbers and logic could be reduced to two states. Today every chip on Earth runs on his idea.

History of the binary number system

Ancient Egyptian and Indian mathematicians used binary-like systems for various calculations, but Gottfried Wilhelm Leibniz in 1703 wrote the first formal exposition of binary arithmetic in "Explication de l'Arithmétique Binaire." He suggested it as the simplest possible number system: everything is 0 or 1.

Binary remained an academic curiosity until George Boole's algebra (1847) showed how logic operations (AND, OR, NOT) could be formalised on binary values. Claude Shannon's 1937 master's thesis demonstrated that electronic switches could implement Boolean logic. The combination — binary representation plus Boolean logic — became the architecture of every digital computer built since the 1940s.

Base equivalents for common values
0 = 0₂ = 0₈ = 0₁₆
10 = 1010₂ = 12₈ = A₁₆
16 = 10000₂ = 20₈ = 10₁₆
42 = 101010₂ = 52₈ = 2A₁₆
255 = 11111111₂ = 377₈ = FF₁₆
65535 = 16 bits all set = FFFF₁₆

Converting binary to decimal

Read the binary digits from right to left. The rightmost bit is multiplied by 2⁰ = 1, the next by 2¹ = 2, then 2² = 4, 2³ = 8, and so on. Sum the products. 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 11.

To go from decimal to binary, divide by 2 and collect the remainders. 42 ÷ 2 = 21 remainder 0. 21 ÷ 2 = 10 remainder 1. 10 ÷ 2 = 5 remainder 0. Continue until the quotient is 0, then read the remainders bottom-up: 101010. The converter does both directions instantly with arbitrary-precision integers.

Converting binary to hexadecimal

Binary and hex are directly related: 4 bits = 1 hex digit. Group binary bits in fours from the right, then map each group to a hex character. 11011001 splits into 1101 1001, which maps to D9. Going the other way, expand each hex digit into 4 bits: 0xFF = 1111 1111. No decimal arithmetic is needed for the conversion.

This compact mapping is why hex dominates computer documentation. A 32-bit value like 0x12345678 is far easier to read than the 32-character binary 00010010001101000101011001111000. Memory addresses, colour codes, MAC addresses, and instruction encodings all use hex for this reason.

Bit widths, bytes, and signed numbers

Hardware imposes natural bit boundaries. The 8-bit byte holds values 0 to 255 (unsigned) or -128 to 127 (signed two's complement). A 16-bit short holds 0 to 65,535 unsigned. A 32-bit integer (the size of an IPv4 address) holds 0 to 4,294,967,295. A 64-bit integer reaches about 1.8 × 10¹⁹.

  • 1 bit = 0 or 1
  • 1 nibble = 4 bits = 0 to 15 = 1 hex digit
  • 1 byte = 8 bits = 0 to 255 = 2 hex digits
  • 1 short = 16 bits = 0 to 65,535
  • 1 int (32-bit) = 0 to 4,294,967,295
  • 1 long (64-bit) ≈ 0 to 1.84 × 10¹⁹
  • IPv4 address = 32 bits = 4 bytes
  • IPv6 address = 128 bits = 16 bytes

Where binary is used in computing

Every computer instruction is a binary pattern. CPU registers, memory cells, and disk sectors all store bits. Networking protocols transmit binary frames; the TCP and IP headers are bit-level layouts. Image files store pixel colours as bytes (each colour channel is 8 bits, 0-255). Crypto algorithms operate on bit patterns directly via XOR and other bitwise operations.

Decimal 42
42
Base 10, 2 digits
Binary 42
101010
Base 2, 6 digits

Programmers see decimals when reading display values, hex when debugging memory, and binary when manipulating bit masks. Switching between the three is one of the most common tasks in low-level programming. Higher-level languages hide most of it, but kernels, drivers, embedded firmware, and crypto code work in raw bits all day.

Common binary-conversion mistakes

Three mistakes recur. First, miscounting bits. A 32-bit integer has 32 bits, not 32 bytes. A 32-bit number written in hex needs 8 hex digits (32 ÷ 4), not 32. Always check digit count when reading binary or hex literals. Second, mixing signed and unsigned interpretations. The bit pattern 0xFF is 255 unsigned but -1 in 8-bit signed two's complement. Computer architectures need to know which interpretation applies. Third, confusing prefix conventions. 0x2A is hex 42, 0b101010 is binary 42, 0o52 is octal 42 — the prefix matters. A bare "101010" could mean any of decimal, binary, or octal depending on context.

Tip

In modern code, use base prefixes: 0b for binary, 0o for octal, 0x for hex, and no prefix for decimal. JavaScript, Python, Rust, and most other languages recognise all four. This eliminates ambiguity when reading literals in source code.

Signed vs unsigned matters

The bit pattern 0xFFFFFFFF can mean two very different numbers. As an unsigned 32-bit integer it is 4,294,967,295. As a signed 32-bit integer in two's complement it is -1. The pattern is identical; only the type interpretation differs. C, Rust, and other low-level languages distinguish; JavaScript and Python infer from context.

FAQ

Treat each binary digit as a power of 2, starting from 0 on the right. 101 in binary equals 1×4 + 0×2 + 1×1 = 5 in decimal. For longer numbers, the principle is identical: each 1 contributes its place value (1, 2, 4, 8, 16,...) to the sum.
42 = 101010 in binary, or 0x2A in hex, or 52 in octal. Reading right to left: 0×1 + 1×2 + 0×4 + 1×8 + 0×16 + 1×32 = 2 + 8 + 32 = 42.
1 byte = 8 bits. A byte holds values from 0 to 255 (unsigned) or -128 to 127 (signed two's complement). Older mainframes used 6, 7, 9, or 36-bit words, but every modern computer uses 8-bit bytes.
4,294,967,295 unsigned (2³² - 1, or 0xFFFFFFFF), or 2,147,483,647 signed (2³¹ - 1). The largest 32-bit signed minimum is -2,147,483,648. Every classic IPv4 address is a 32-bit unsigned integer.
Group the binary digits into nibbles of 4 (from the right) and map each nibble to a single hex character: 0000 → 0, 1001 → 9, 1010 → A, 1111 → F. So 11011001 splits into 1101 1001, which maps to D9 in hex. No decimal step required.
Hex (base 16) is the standard human-readable form of binary because each hex digit packs 4 bits. Used in colour codes (#FF8800), memory addresses (0x7FFE0000), MAC addresses, byte arrays, file dumps, and machine code. Far more compact than binary, more legible than decimal for bit patterns.
Octal (base 8) groups bits in threes. Its main modern use is Unix file permissions: chmod 755 maps to rwxr-xr-x, where 7 = 111 (read+write+execute), 5 = 101 (read+execute). Historically octal was used by PDP-11 and other mini-computers with 6-bit or 12-bit words.
Yes. The converter uses JavaScript BigInt, which handles arbitrarily long integers without precision loss. You can input a 100-digit decimal number and see its exact binary, hex, and octal representations. There is no 32-bit or 64-bit ceiling.