Xerobit

Decimal to Binary Converter

Enter a base-10 integer to see its binary (base-2) equivalent. The converter handles arbitrarily large numbers exactly using BigInt arithmetic, and offers an optional signed two's complement mode for negative values. Everything runs locally in your browser without uploading data.

Represent negative numbers using two's complement with the minimum required bits.

Result

  • Binary
    101010
  • Bits
    6

How to use the decimal to binary

  1. Type or paste a base-10 integer into the Decimal number field.
  2. Check Signed (two's complement) if you need the binary form used by computers for negative numbers.
  3. Read the binary string and bit count in the result area immediately as you type.

How decimal to binary conversion works

The standard method for converting a positive integer from base 10 to base 2 is repeated division by 2. You divide the number by 2, record the remainder (which is always 0 or 1), then repeat with the quotient until it reaches zero. Reading the remainders in reverse order gives the binary string.

For example, converting 42:

  • 42 / 2 = 21 remainder 0
  • 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

Reading the remainders from bottom to top yields 101010. This tool performs the same logic internally using BigInt division so that even numbers with hundreds of digits are converted exactly without floating-point rounding errors.

Two's complement for negative numbers

When the Signed option is enabled, negative integers are represented in two's complement form. This is the encoding scheme used by virtually all modern processors to store signed integers.

To compute the two's complement of a negative number manually, first write the positive value in binary, invert every bit (change 0 to 1 and 1 to 0), then add 1. For example, to represent -13:

  1. Positive 13 in binary is 01101 (using 5 bits to leave room for the sign).
  2. Invert the bits: 10010.
  3. Add 1: 10011.

The result 10011 is the 5-bit two's complement representation of -13. The most significant bit is always 1 for negative values and 0 for non-negative values. This converter automatically selects the minimum number of bits needed so the leading bit correctly indicates the sign.

Common decimal to binary values

This reference table lists frequently used powers of two and small integers alongside their binary equivalents. These values appear often in networking, permissions, and low-level programming.

DecimalBinaryBits
001
111
2102
71113
810004
1511114
16100005
12711111117
128100000008
255111111118
2561000000009
10241000000000011

Practical uses for binary conversion

Understanding how to move between denary (base 10) and binary (base 2) is essential in several technical fields:

  • Subnet masks and IP addressing: IPv4 addresses are 32-bit numbers. Network engineers convert each octet to binary to calculate subnet boundaries and CIDR notation.
  • File permissions: Unix file permissions are often expressed as three octal digits, but underneath they are nine binary flags (read, write, execute for owner, group, and others).
  • Digital electronics: Logic gates operate on high and low voltage levels that map directly to 1 and 0. Designers convert specification values to binary to configure registers.
  • Bitwise operations: When working with flags or masks in code, developers convert integers to binary to visualize which bits will be set, cleared, or toggled by AND, OR, and XOR operations. See the bitwise calculator for performing those operations.

Worked examples

ExampleInputResult
Small positive integerDecimal number: 42; Signed (two's complement): noBinary: 101010; Bits: 6
One byte maxDecimal number: 255; Signed (two's complement): noBinary: 11111111; Bits: 8
Negative with two's complementDecimal number: -13; Signed (two's complement): yesBinary: 10011; Bits: 5
ZeroDecimal number: 0; Signed (two's complement): noBinary: 0; Bits: 1
Large integerDecimal number: 1000000; Signed (two's complement): noBinary: 11110100001001000000; Bits: 20

FAQ

How do I convert a decimal number to binary?

Divide the number by 2 repeatedly, recording the remainder each time. When the quotient reaches 0, read the remainders from last to first. For example, 10 divided by 2 gives remainder 0, then 5 gives 1, then 2 gives 0, then 1 gives 1, producing 1010.

What is two's complement?

Two's complement is the standard way computers represent negative integers in binary. You invert all the bits of the positive number and add 1. The most significant bit acts as the sign indicator.

Can this tool handle very large numbers?

Yes. The converter uses BigInt arithmetic internally, so it can process integers with hundreds or thousands of digits without losing precision.

Does this support decimal fractions like 3.14?

No. This tool converts whole integers only. Fractional parts require a different algorithm that repeatedly multiplies the fraction by 2. For IEEE 754 floating-point representations, use the dedicated float converter.

Is my data sent to a server?

No. The conversion happens entirely in your browser using JavaScript. Nothing is uploaded or transmitted.

Why does -1 show as just '1' in signed mode?

In two's complement with the minimum bit width, -1 requires only 1 bit. A single bit set to 1 represents -1 because the formula is -(2^0) = -1. With more fixed-width bits (like 8-bit), -1 would be 11111111.