Skip to content
KmapGen

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.

Type in any box; the others update. Fractions are allowed (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

DivisionQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Read the remainders from bottom to top: 10011100.

Fractional part: multiply by 2 and keep the integer parts

MultiplyResultDigit
0.625 × 21.251
0.25 × 20.50
0.5 × 211

Read the digits from top to bottom.

0 to 15 in binary, octal and hex

DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

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.