toolqik

89 · Encode & Convert

Decimal to Binary

Convert decimal numbers to binary, including fractions, negatives and huge numbers.

Runs in your browser
Format
Result

  

About this tool

Convert decimal (base 10) numbers to binary (base 2). Enter one or many numbers, one per line, and get the binary for each, plus the first number in every base. Works for whole numbers of any size, fractions and negative numbers.

How to convert decimal to binary by hand

Divide by 2 repeatedly and write down the remainders; reading them from the last to the first gives the binary number. For 13:

13 ÷ 2 = 6  remainder 1
 6 ÷ 2 = 3  remainder 0
 3 ÷ 2 = 1  remainder 1
 1 ÷ 2 = 0  remainder 1      → read upwards: 1101

For a fraction, multiply by 2 repeatedly and take the integer parts: 0.625 × 2 = 1.25, 0.25 × 2 = 0.5, 0.5 × 2 = 1.0 → 0.101. Some decimals, like 0.1, never end in binary (0.000110011…). That’s why 0.1 + 0.2 isn’t exactly 0.3 in most programming languages.

Negative numbers and two’s complement

Computers store signed integers in two’s complement: invert all the bits of the positive number and add 1. In 8 bits, −5 is 11111011. Choose a bit width under Negative numbers to get that form instead of a minus sign.

Features

  • Any size: numbers are converted exactly with arbitrary-precision arithmetic, so 64-bit values and even longer numbers never lose digits (a normal calculator rounds anything above 253).
  • Fractions: 3.75 → 11.11. Fractions that don’t end in the target base, like 0.1 in binary, are cut off after the chosen number of digits and marked with ….
  • Negative numbers with a minus sign, or as two’s complement in 8, 16, 32 or 64 bits, the way computers store signed integers.
  • Flexible input: prefixes (0b, 0o, 0x, #), spaces, underscores and thousands separators are ignored. Convert many numbers at once, one per line.
  • The first number is also shown in every base, with the number of bits it needs.

Quick reference

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
711177
81000108
91001119
10101012A
15111117F
16100002010
321000004020
64100000010040
100110010014464
12711111111777F
1281000000020080
25511111111377FF
256100000000400100
1024100000000002000400

FAQ

How do I convert decimal to binary?

Enter the number and its binary form appears instantly. By hand, divide by 2 repeatedly and read the remainders from bottom to top.

What is 10 in binary?

1010. And 255 is 11111111, 256 is 100000000.

How do I convert a decimal fraction to binary?

Multiply the fractional part by 2 repeatedly and take the integer digit each time. Enter a fraction such as 3.75 to get 11.11.

How are negative numbers converted?

With a minus sign by default (−101). Choose 8, 16, 32 or 64-bit two’s complement to get the bit pattern a computer stores, such as 11111011 for −5 in 8 bits.

Is there a size limit?

No. Numbers are converted with arbitrary-precision arithmetic, so even numbers far beyond 64 bits are exact.

esc
↑↓ navigate↵ open