gettoolz.app

Decimal to binary converter

Convert decimal numbers to binary — by repeated division by 2, every step shown. Exact at any size, with a worked example and a table of common values. Free, and computed in your browser.

Part of developer tools.

Base

Binary

10101101

Octal

255

Decimal

173

Hexadecimal

AD

Decimal to binary table

DecimalBinary
00
11
210
311
4100
5101
6110
7111
81000
91001
101010
111011
121100
131101
141110
151111
1610000
1001100100
1271111111
25511111111
256100000000
10001111101000
102410000000000
40961000000000000
655351111111111111111
429496729511111111111111111111111111111111
184467440737095516151111111111111111111111111111111111111111111111111111111111111111

The last rows are the largest 32-bit and 64-bit unsigned values. The second is past the point where ordinary JavaScript numbers start rounding; the table and the converter above both compute with BigInt, so every digit is exact.

How to convert decimal to binary

Divide the decimal number by 2, write down the remainder, and repeat with the quotient until it reaches 0. The remainders, read from the last one back to the first, are the binary digits. For 173: 173 ÷ 2 = 86 remainder 1; 86 ÷ 2 = 43 remainder 0; 43 ÷ 2 = 21 remainder 1; 21 ÷ 2 = 10 remainder 1; 10 ÷ 2 = 5 remainder 0; 5 ÷ 2 = 2 remainder 1; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1. Read upwards, that is 10101101. For small numbers it is often quicker to take away the largest power of two that fits, again and again, and write a 1 for each power used: 173 = 128 + 32 + 8 + 4 + 1.

Decimal and binary side by side

The largest 16-bit value is 65535 in decimal and 1111111111111111 in binary: 5 digits against 16. A decimal digit is worth log₂ 10 ≈ 3.32 bits — not a whole ratio, so decimal and binary digits never line up and there is no digit-by-digit shortcut: the whole number has to be divided down, as above. Binary is what bit masks, flags and subnet masks are reasoned in: a /24 network mask is twenty-four 1 bits followed by eight 0 bits, 255.255.255.0 once written in decimal. In JavaScript and Python source, 173 is written 173 with no prefix in decimal and 0b10101101 in binary. Paste a prefixed number into the converter and it switches to the matching base; a number with no prefix is read in the selected base — decimal on this page.

Other conversions

Going the other way? Binary to decimal converter.

Or open the full number base converter and see a number in all four bases at once.