Binary, Hex, Octal and Decimal Converter
Convert between number bases with fractions and arbitrarily large integers. Repeating digits are detected exactly, and the decimal-to-binary steps are shown.
0.1, FF.8); a repeating block is shown in parentheses, e.g. 0.110 = 0.0(0011)2.
Decimal → binary, step by step
Integer part 156: divide by 2 and keep the remainders
| Division | Quotient | Remainder |
|---|---|---|
| 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 |
Read the remainders from bottom to top: 10011100.
Fractional part: multiply by 2 and keep the integer parts
| Multiply | Result | Digit |
|---|---|---|
| 0.625 × 2 | 1.25 | 1 |
| 0.25 × 2 | 0.5 | 0 |
| 0.5 × 2 | 1 | 1 |
Read the digits from top to bottom.
0 to 15 in binary, octal and hex
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
How positional notation works
In base b, each digit is multiplied by a power of b that depends on its position: 2A.816 = 2 × 16 + 10 × 1 + 8 × 16−1 = 42.5. To convert from any base to decimal, expand it this way; to convert from decimal to any base, use repeated division (integer part) and repeated multiplication (fractional part), as the step table above shows.
Binary, octal and hex convert into each other without going through decimal, by grouping bits in threes or fours. That is why hex is the usual shorthand for bit patterns such as IEEE 754 floats and two’s complement integers.
Frequently asked questions
How do I convert decimal to binary?
Divide the number by 2 repeatedly and write down the remainders; reading them from the last to the first gives the binary digits. 156 → 78 r0 → 39 r0 → 19 r1 → 9 r1 → 4 r1 → 2 r0 → 1 r0 → 0 r1, so 156 = 100111002. For a fraction, multiply by 2 repeatedly and keep the integer parts: 0.625 → 1.25 (1) → 0.5 (0) → 1.0 (1), so 0.625 = 0.1012.
How do I convert binary to hexadecimal?
Group the bits in fours starting from the binary point and replace each group by its hex digit: 1001 1100 = 9C. For octal, group in threes: 010 011 100 = 2348. This works because 16 = 24 and 8 = 23.
Why does 0.1 have no exact binary representation?
A fraction terminates in base b only if its denominator (in lowest terms) has no prime factors other than those of b. 0.1 = 1/10 and 10 = 2 × 5; the factor 5 is not a factor of 2, so in binary 0.1 repeats forever: 0.0001100110011…2. The same thing happens to 1/3 in decimal.
What bases can this converter handle?
Binary, octal, decimal and hexadecimal side by side, plus any base from 2 to 36 (digits 0–9 then A–Z). Numbers may be negative and have a fractional part; integers can be arbitrarily large.
Related tools and guides
- Two's complement Convert between decimal and two's complement binary or hex for any width up to 256 bits. Steps, ranges, one's complement, sign-magnitude and overflow flags.
- IEEE 754 converter IEEE 754 converter for single, double, half precision and bfloat16: decimal ↔ hex ↔ binary, clickable bits, the exact stored value and the rounding error.
- Logic gates All seven logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) with ANSI and IEC symbols, truth tables, expressions and NAND/NOR-only circuits.
- Truth table generator Generate the truth table of any Boolean expression (AND, OR, NOT, XOR, NAND, NOR, →, ↔) with step columns, minterms, SOP/POS and CSV or LaTeX export.