Skip to the tool
CALCPARK

Binary, Decimal & Hex Converter

Convert whole numbers between binary, octal, decimal, hex and any base 2–36. Any size (BigInt), negatives with a two’s-complement view, and every digit’s place value.

Runs on your device
Loading the tool…

How to use it

  1. Type a number in the field of the base you have – binary, octal, decimal, hexadecimal or a custom base from 2 to 36. Prefixes such as 0x and 0b and separators (spaces, underscores, commas) are ignored.
  2. The other fields update as you type; the result panel lists every base with a copy button.
  3. Read the place-value table to see how each digit contributes (digit × base^position) and where the decimal value comes from.
  4. For a negative number, or to see a fixed-width pattern, pick 8, 16, 32 or 64 bits under Two’s complement.

Example

Hex 2f to decimal: 2 × 16¹ + 15 × 16⁰ = 32 + 15 = 47. To binary, replace each hex digit by four bits: 2 = 0010, f = 1111, so 2f = 0010 1111 = 101111. Decimal 47 to octal by repeated division: 47 ÷ 8 = 5 remainder 7, 5 ÷ 8 = 0 remainder 5, read the remainders upwards: 57. And −47 in 8-bit two’s complement is 256 − 47 = 209 = 1101 0001 (d1).

How the conversion works

A number written with digits dn … d1 d0 in base b has the value

value = dₙ·bⁿ + … + d₁·b¹ + d₀·b⁰
1011₂ = 1·8 + 0·4 + 1·2 + 1·1 = 11

To write a value in another base, divide by that base repeatedly and collect the remainders from last to first (255 ÷ 16 = 15 r 15 → ff). Because 8 = 2³ and 16 = 2⁴, binary groups of three bits map directly to octal digits and groups of four to hex digits, which is why programmers prefer hex for bytes, addresses and colours (#ff8800). The tool keeps every value as an arbitrary-precision integer, so inputs longer than 64 bits convert exactly; fractional values are not supported.

Two’s complement represents a negative number −x in w bits as 2w − x, so the top bit is 1 for negatives and arithmetic wraps naturally. An 8-bit signed integer runs from −128 (80) to 127 (7f); the same pattern 80–ff reads as 128–255 when treated as unsigned. The converter reports when a positive input has its top bit set for the chosen width.

Conversion table

DecimalBinaryOctalHex
0000
1111
21022
711177
81000108
10101012a
15111117f
16100002010
100110010014464
25511111111377ff
256100000000400100
1,024100000000002000400
4,0951111111111117777fff
65,5351111111111111111177777ffff

Sources: Wikipedia – Positional notation, Wikipedia – Two’s complement, MDN – BigInt (arbitrary-precision integers used by this tool).

Prefixes and notation

Programming languages mark the base with a prefix: 0b1010 (binary), 0o12 or a leading 0 (octal, in C), 0xa (hexadecimal). In mathematics a subscript is used instead: 1010₂ = 12₈ = 10₁₀ = a₁₆. Letters in hex may be upper or lower case; CSS colour codes, MAC addresses and hashes are hex; base 32 and base 36 (digits plus the whole alphabet) appear in short URLs and licence keys.

Questions

How do I convert binary to decimal?
Add up the place values of every 1 bit, doubling from 1 at the right: 1011 = 8 + 0 + 2 + 1 = 11. The place-value table in the tool shows exactly this sum.
How do I convert decimal to hexadecimal?
Divide by 16 repeatedly and write the remainders backwards, using a–f for 10–15: 255 ÷ 16 = 15 r 15, 15 ÷ 16 = 0 r 15, so 255 = ff. 4,096 = 1000 hex.
What is −1 in binary?
There is no single answer without a width. With a sign it is simply −1; in 8-bit two’s complement it is 11111111 (ff), in 16 bits ffff and in 32 bits ffffffff. Select the width in the tool to see each form.
Can it convert very large numbers?
Yes. Values are handled as arbitrary-precision integers, so a 256-bit hash or a 100-digit decimal converts exactly; the place-value breakdown is shown for inputs of up to 32 digits.