Digital Logic Toolkit — Binary ⇄ decimal ⇄ hex ⇄ octal
Number Base Converter
Binary ⇄ decimal ⇄ hexadecimal ⇄ octal, with every step of the arithmetic.
Value
Input base
Display
Rounding
Textbooks usually truncate. State which your course expects.
Bit grouping
Binary
1101.101
7 digits · 1 byte
Octal
15.5
3 digits
Decimal
13.625
5 digits
Hexadecimal
D.A
2 digits
Group outward from the radix point: pad the integer side on the left and the fraction side on the right.
Working — binary
Base 10 to base 2
Convert 13.625 from base 10 to base 2. The sign is carried across unchanged; only the magnitude is converted.
| digit | value | weight | weight (base 10) | digit x weight |
|---|---|---|---|---|
| 1 | 1 | 10^1 | 10 | 10 |
| 3 | 3 | 10^0 | 1 | 3 |
| 6 | 6 | 10^-1 | 0.1 | 0.6 |
| 2 | 2 | 10^-2 | 0.01 | 0.02 |
| 5 | 5 | 10^-3 | 0.001 | 0.005 |
| total | 13.625 |
Integer part: divide by 2 and read the remainders bottom to top.
| n | divide by | quotient | remainder |
|---|---|---|---|
| 13 | 13 ÷ 2 | 6 | 1 |
| 6 | 6 ÷ 2 | 3 | 0 |
| 3 | 3 ÷ 2 | 1 | 1 |
| 1 | 1 ÷ 2 | 0 | 1 |
Fraction part: multiply by 2 and read the digits top to bottom.
| fraction | multiply by | product | digit |
|---|---|---|---|
| 0.625 | 0.625 × 2 | 1.25 | 1 |
| 0.25 | 0.25 × 2 | 0.5 | 0 |
| 0.5 | 0.5 × 2 | 1 | 1 |
13.625 (base 10)1101.101 (base 2)
Working — octal
Base 10 to base 8
Convert 13.625 from base 10 to base 8. The sign is carried across unchanged; only the magnitude is converted.
| digit | value | weight | weight (base 10) | digit x weight |
|---|---|---|---|---|
| 1 | 1 | 10^1 | 10 | 10 |
| 3 | 3 | 10^0 | 1 | 3 |
| 6 | 6 | 10^-1 | 0.1 | 0.6 |
| 2 | 2 | 10^-2 | 0.01 | 0.02 |
| 5 | 5 | 10^-3 | 0.001 | 0.005 |
| total | 13.625 |
Integer part: divide by 8 and read the remainders bottom to top.
| n | divide by | quotient | remainder |
|---|---|---|---|
| 13 | 13 ÷ 8 | 1 | 5 |
| 1 | 1 ÷ 8 | 0 | 1 |
Fraction part: multiply by 8 and read the digits top to bottom.
| fraction | multiply by | product | digit |
|---|---|---|---|
| 0.625 | 0.625 × 8 | 5 | 5 |
13.625 (base 10)15.5 (base 8)
Working — decimal
Base 10 to base 10
Convert 13.625 from base 10 to base 10. The sign is carried across unchanged; only the magnitude is converted.
| digit | value | weight | weight (base 10) | digit x weight |
|---|---|---|---|---|
| 1 | 1 | 10^1 | 10 | 10 |
| 3 | 3 | 10^0 | 1 | 3 |
| 6 | 6 | 10^-1 | 0.1 | 0.6 |
| 2 | 2 | 10^-2 | 0.01 | 0.02 |
| 5 | 5 | 10^-3 | 0.001 | 0.005 |
| total | 13.625 |
Integer part: divide by 10 and read the remainders bottom to top.
| n | divide by | quotient | remainder |
|---|---|---|---|
| 13 | 13 ÷ 10 | 1 | 3 |
| 1 | 1 ÷ 10 | 0 | 1 |
Fraction part: multiply by 10 and read the digits top to bottom.
| fraction | multiply by | product | digit |
|---|---|---|---|
| 0.625 | 0.625 × 10 | 6.25 | 6 |
| 0.25 | 0.25 × 10 | 2.5 | 2 |
| 0.5 | 0.5 × 10 | 5 | 5 |
13.625 (base 10)13.625 (base 10)
Working — hexadecimal
Base 10 to base 16
Convert 13.625 from base 10 to base 16. The sign is carried across unchanged; only the magnitude is converted.
| digit | value | weight | weight (base 10) | digit x weight |
|---|---|---|---|---|
| 1 | 1 | 10^1 | 10 | 10 |
| 3 | 3 | 10^0 | 1 | 3 |
| 6 | 6 | 10^-1 | 0.1 | 0.6 |
| 2 | 2 | 10^-2 | 0.01 | 0.02 |
| 5 | 5 | 10^-3 | 0.001 | 0.005 |
| total | 13.625 |
Integer part: divide by 16 and read the remainders bottom to top.
| n | divide by | quotient | remainder |
|---|---|---|---|
| 13 | 13 ÷ 16 | 0 | D |
Fraction part: multiply by 16 and read the digits top to bottom.
| fraction | multiply by | product | digit |
|---|---|---|---|
| 0.625 | 0.625 × 16 | 10 | A |
13.625 (base 10)D.A (base 16)
Notation used on this page
- Most significant digit first, left to right. A subscript names the base.
- The prefixes 0b, 0o and 0x are accepted on input and never emitted on output.
- Digits A–F are case-insensitive on input and upper case on output.
- A repeating expansion is written with its repetend in parentheses, as 0.0(0011).
Start from a worked example
Which converter do you need?
- Converting numbers between bases — you are on the right page.
- Converting text to and from character codes — use the binary to text converter.
- Converting negative numbers — use the two’s complement converter.
People search for a binary converter meaning either of the first two; this page does the number one.
Positional notation: what a base actually means
A number written in base b is a sum of its digits multiplied by powers of b: value = Σ dᵢ·bⁱ, where the exponent is the digit’s distance from the radix point — counting up to the left and down to the right. Base b uses the digits 0 to b−1; hexadecimal borrows the letters A to F for the values 10 to 15, because there are no single decimal digits for them.
| Base | Digits | Bits per digit |
|---|---|---|
| Binary (2) | 0 1 | 1 |
| Octal (8) | 0–7 | 3 |
| Decimal (10) | 0–9 | — |
| Hexadecimal (16) | 0–9 A–F | 4 |
Binary to decimal
Write the power of two above each column and add the columns that hold a 1. For 11010110₂: 1×2⁷ + 1×2⁶ + 0×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰ = 128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = 214₁₀. The zero terms are written out rather than skipped: the method is what you are graded on, and a dropped column is where the digits slip.
Decimal to binary
Divide by two repeatedly and keep the remainders: 156 → 78 r0 → 39 r0 → 19 r1 → 9 r1 → 4 r1 → 2 r0 → 1 r0 → 0 r1, giving 10011100₂.
The remainders are read bottom to top — from the last division back to the first. Reading them top to bottom is the single most common error in this conversion, and it produces a number that looks plausible and is wrong.
Binary to hexadecimal, and back
Between base 2, 8 and 16 you do not need division: 8 = 2³ and 16 = 2⁴, so three or four binary digits map to exactly one octal or hexadecimal digit. Group 110111011010₂ into fours from the radix point — 1101 1101 1010 — and read each group as a digit: D, D, A, so DDA₁₆ (3546₁₀). Backwards, 2AF₁₆ expands to 0010 1010 1111 = 1010101111₂ (687₁₀), where the two leading zeros are padding rather than data.
| Binary | Decimal | Hex | Octal |
|---|---|---|---|
| 0000 | 0 | 0 | 0 |
| 0001 | 1 | 1 | 1 |
| 0010 | 2 | 2 | 2 |
| 0011 | 3 | 3 | 3 |
| 0100 | 4 | 4 | 4 |
| 0101 | 5 | 5 | 5 |
| 0110 | 6 | 6 | 6 |
| 0111 | 7 | 7 | 7 |
| 1000 | 8 | 8 | 10 |
| 1001 | 9 | 9 | 11 |
| 1010 | 10 | A | 12 |
| 1011 | 11 | B | 13 |
| 1100 | 12 | C | 14 |
| 1101 | 13 | D | 15 |
| 1110 | 14 | E | 16 |
| 1111 | 15 | F | 17 |
Binary to octal, and back
Octal works the same way with groups of three. 11110110111₂ is eleven bits, so the integer side is padded on the left to twelve: 011 110 110 111 → 3, 6, 6, 7 → 3667₈ (1975₁₀). Octal survives in Unix file permissions for exactly this reason: three permission bits are one octal digit.
Decimal to hexadecimal and octal
Repeated division takes any base as its divisor. 1975 ÷ 16 gives 123 r7, then 7 r11, then 0 r7 — and a remainder of 11 is written B, so 1975₁₀ = 7B7₁₆. Dividing the same number by 8 gives 246 r7, 30 r6, 3 r6, 0 r3, so 1975₁₀ = 3667₈, which agrees with the grouping above.
Fractions and the radix point
A fractional part converts by repeated multiplication, and its integer parts are read top to bottom — the opposite direction to the division table. For 0.625: 0.625 × 2 = 1.25 (digit 1), 0.25 × 2 = 0.5 (digit 0), 0.5 × 2 = 1.0 (digit 1), giving .101₂. With the integer part, 13.625₁₀ is 1101.101₂.
Grouping runs outward from the radix point: pad the integer side on the left and the fraction side on the right. 1101.101₂ is D.A₁₆ — the fraction 101 pads right to 1010 = A.
Common mistake
Padding the fraction on the left gives the wrong answer. .101₂ is .A₁₆ (pad right to 1010), not .5₁₆, which is what left-padding to 0101 would give.
Non-integers inside a computer are usually not stored this way at all: they use IEEE 754 binary floating point, whose layout is described on the two’s complement page and standardised in IEEE 754-2019 (opens in a new tab).
Repeating expansions
A fraction terminates in base b if and only if, written in lowest terms, every prime factor of the denominator is also a factor of b.
1/10 = 1/(2·5), and 5 does not divide 2, so 0.1 has no terminating binary form: it is 0.0(0011)₂, one non-repeating digit followed by a four-digit repetend. By the same rule 1/3 is 0.(01)₂ with period 2, 1/7 is 0.(001)₂ with period 3, and 1/5 in octal is 0.(1463)₈ with period 4. This is also why 0.1 + 0.2 is not 0.3 in any language that stores numbers in binary floating point.
Signed values
A bit pattern on its own has no sign. 10110110is 182 read as unsigned and −74 read as 8-bit two’s complement. Only the width and the convention you declare decide which.
This page shows the unsigned reading in the four result cards and the signed reading beside them whenever the value is an integer that fits the chosen width. The two’s complement converter shows the complement chain, the range check and sign extension in full.
Large numbers
Every conversion here runs on arbitrary-precision integers and exact rationals, so a value above 2⁵³−1 is exact — which it is not in converters built on double-precision numbers. The demonstration is 2⁶⁴ − 1 = 18446744073709551615 = FFFFFFFFFFFFFFFF₁₆. A tool that answers 18446744073709552000 is telling you about its own arithmetic, not about your number.
Notation used on this page
- Most significant digit first, left to right; a subscript names the base.
- The prefixes
0b,0oand0xare accepted on input and never emitted on output. - Digits A–F are case-insensitive on input and upper case on output.
- A repeating expansion is marked with an overline on screen and with parentheses in copied text, as
0.0(0011). - Fractions are truncated at the digit budget by default rather than rounded. Textbooks differ; state which convention your course expects.
Sources
Positional notation and radix conversion are stated here as definitions rather than attributed to a source. The one external standard this page relies on is IEEE 754-2019, IEEE Standard for Floating-Point Arithmetic (opens in a new tab), cited in the section on fractions.
Worked examples
- 156₁₀ → binaryintrorepeated division by 2
- 1011 0110₂ → decimalintropositional expansion
- 0.625₁₀ → binarycoreterminating fraction
- 0.1₁₀ → binarycorenon-terminating in base 2
- 3F7₁₆ → decimalcorepositional expansion in base 16
- 1101 1010₂ → hex and octalcoregrouping by 4 and by 3 bits
- 255₁₀ → hexcorethe byte boundary
- 777₈ → decimalexambase 8 positional expansion
- 2AF₁₆ → octalexamroute through binary, not decimal
- 1024₁₀ → binary, hex and octaledge caseone value in four bases at once