>_

Decimal to Binary

Type a decimal number below to get the binary value — other bases are shown too. The manual method is explained further down.

Try it

Custom base

Two’s complement

How to convert by hand

Divide by 2 repeatedly, note each remainder, then read the remainders from bottom to top:
42 ÷ 2 = 21 … 0
21 ÷ 2 = 10 … 1
10 ÷ 2 = 5 … 0
5 ÷ 2 = 2 … 1
2 ÷ 2 = 1 … 0
1 ÷ 2 = 0 … 1
→ 101010

Reference table

Decimal → Binary

0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
32 100000
64 1000000
100 1100100
127 1111111
128 10000000
255 11111111
256 100000000
1000 1111101000
1024 10000000000
4096 1000000000000
65535 1111111111111111

In code

JavaScript

(42).toString(2) // '101010'

Python

format(42, 'b')  # '101010'  (bin(42) → '0b101010')

More examples

Open the full Number Base Converter →