Math
Number system converter
Type a number, choose the base it is written in and the base you want. The converter gives the result, the same value in binary, octal, decimal and hex, and the working for both the whole part and the fraction.
Digits above 9 are letters: A = 10, B = 11, … Z = 35.
| Divide | ÷ 2 | Quotient | Remainder (digit) |
|---|---|---|---|
| 156 | 2 | 78 | 0 |
| 78 | 2 | 39 | 0 |
| 39 | 2 | 19 | 1 |
| 19 | 2 | 9 | 1 |
| 9 | 2 | 4 | 1 |
| 4 | 2 | 2 | 0 |
| 2 | 2 | 1 | 0 |
| 1 | 2 | 0 | 1 |
Show the working, step by step
Integer part: divide 156 by 2 repeatedly, writing down each remainder, until the quotient is 0.
156 ÷ 2 = 78 remainder 0 78 ÷ 2 = 39 remainder 0 39 ÷ 2 = 19 remainder 1 19 ÷ 2 = 9 remainder 1 9 ÷ 2 = 4 remainder 1 4 ÷ 2 = 2 remainder 0 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1
Read the remainders from the last one up to the first.
156 = 10011100₂
Fraction part: multiply by 2. The whole-number part of the result is the next digit; carry on with what is left after the point.
0.625 × 2 = 1 + 0.25 → digit 1 0.25 × 2 = 0 + 0.5 → digit 0 0.5 × 2 = 1 + 0 → digit 1
The fraction reached 0, so the digits end here. Read them from top to bottom.
0.101
Result:
156.625₁₀ = 10011100.101₂
How place value works in any base
dₖ…d₁d₀.d₋₁d₋₂… in base b = Σ dᵢ × bⁱ 10011100.101₂ = 2⁷ + 2⁴ + 2³ + 2² + 2⁻¹ + 2⁻³ = 156.625
Each position is worth b times the one to its right. Converting into decimal is just this sum. Converting out of decimal runs it backwards: repeated division peels off the digits of the whole part from the right, and repeated multiplication pulls out the digits of the fraction from the left.
A worked example: 156.625 to binary
Whole part, dividing by 2:
156 ÷ 2 = 78 r 0 78 ÷ 2 = 39 r 0 39 ÷ 2 = 19 r 1 19 ÷ 2 = 9 r 1 9 ÷ 2 = 4 r 1 4 ÷ 2 = 2 r 0 2 ÷ 2 = 1 r 0 1 ÷ 2 = 0 r 1 → read upwards: 10011100
Fraction part, multiplying by 2:
0.625 × 2 = 1.25 → 1 0.25 × 2 = 0.5 → 0 0.5 × 2 = 1.0 → 1 → read downwards: .101
So 156.625 = 10011100.101₂. The same value is 234.5 in octal and 9C.A in hexadecimal.
Common bases
| Base | Name | Digits | Used for |
|---|---|---|---|
| 2 | Binary | 0–1 | Computer hardware, bit flags |
| 8 | Octal | 0–7 | Unix file permissions (chmod 755) |
| 10 | Decimal | 0–9 | Everyday counting |
| 16 | Hexadecimal | 0–9, A–F | Colours (#FF8800), memory addresses, bytes |
| 36 | Base 36 | 0–9, A–Z | Short IDs and URL slugs |
Which fractions terminate?
A fraction in lowest terms has a finite expansion in base b exactly when every prime factor of its denominator also divides b. In decimal (2 × 5) that allows halves, quarters, fifths and tenths. In binary only powers of 2 qualify, so 0.5, 0.25 and 0.625 convert exactly but 0.1, 0.2 and 0.3 repeat. In base 3, 1/3 is simply 0.1₃, while 1/2 repeats as 0.(1)₃.
Common mistakes
- Reading the remainders in the wrong order. The first remainder is the last (rightmost) digit.
- Using a digit that is too big. 2 is not a binary digit, and G is not a hex digit; the converter says so.
- Treating a cut-off fraction as exact. If the result ends in “…”, the true expansion carries on.
- Negative numbers in hardware. The converter writes −FF for −255. Computers usually store negatives in two’s complement, which is a different representation.
Common questions
How do I convert decimal to binary?
Divide by 2 repeatedly and write down the remainders, then read them from the last to the first. 156 → 78 r 0 → 39 r 0 → 19 r 1 → 9 r 1 → 4 r 1 → 2 r 0 → 1 r 0 → 0 r 1, so 156 = 10011100₂. For a fraction, multiply by 2 instead and read the whole-number parts from the top: 0.625 → 1.25 → 0.5 → 1.0 gives 0.101₂.
How do I convert binary (or hex) to decimal?
Multiply each digit by its place value and add. 10011100₂ = 128 + 16 + 8 + 4 = 156. In hex the place values are powers of 16 and the letters A–F stand for 10–15, so FF.8₁₆ = 15 × 16 + 15 + 8 ÷ 16 = 255.5.
Why does 0.1 not convert exactly to binary?
A fraction ends in base b only if its denominator (in lowest terms) has no prime factors other than those of b. 0.1 = 1/10 has the factor 5, which 2 lacks, so in binary it repeats for ever: 0.0(0011)₂. That is why computers store 0.1 slightly wrongly and 0.1 + 0.2 comes out as 0.30000000000000004.
What is the quick way between binary, octal and hex?
Group the binary digits from the point: threes for octal, fours for hex. 1001 1100.1010₂ is 9C.A₁₆, and 010 011 100.101₂ is 234.5₈. It works because 8 = 2³ and 16 = 2⁴.
What bases are supported?
Any whole-number base from 2 to 36. Digits above 9 use letters, so base 36 uses 0–9 and A–Z. Integers of any length convert exactly; fractional parts are shown to the number of digits you choose, with repeating blocks in brackets when one is found.
Related calculators
-
Modular arithmetic
Remainders, the heart of base conversion.
-
Division
Repeating decimals by long division.