Calcoid

Decimal to Binary Converter

Convert decimal (base-10) to binary, hex, and octal in one shot. Supports unsigned, signed 8/16/32-bit two's complement, and fractional values like 5.375 = 101.011, with a per-bit place-value breakdown and two's complement step trace.

Decimal to binary, hex, and octal

Negative values are only allowed in a signed mode.

Used only when the input has a fractional part. Many decimals repeat forever in binary, so the conversion may truncate.

Binary representation

1010

4 bits total.

Binary

1010

Hexadecimal

A

Octal

12

Positional value breakdown

Each set bit contributes 2 to the power of its position. Sum the contributions to recover the integer.

  • 238
  • 212
  • Sum10

Frequently Asked Questions about the Decimal to Binary Converter

How do I convert a decimal number to binary by hand?
Use repeated division by 2. Divide the number by 2, write down the remainder (0 or 1), and replace the number with the integer quotient. Repeat until the quotient is 0, then read the remainders from bottom to top. For 13: 13 / 2 = 6 remainder 1, 6 / 2 = 3 remainder 0, 3 / 2 = 1 remainder 1, 1 / 2 = 0 remainder 1. Read bottom to top: 1101. Why it works: each remainder is the value of the next-higher power of 2 in the expansion, because dividing by 2 shifts the binary representation one place to the right and the new remainder is whatever fell off the bottom.
What is two's complement and how do I encode a negative number?
Two's complement is the standard way CPUs represent signed integers. To encode a negative value at N bits: take the absolute value, write it in unsigned binary padded to N bits, flip every bit (one's complement), then add 1. For -5 in 8-bit: |−5| = 5 = 00000101, invert to 11111010, add 1 to get 11111011. The big win is that addition and subtraction work identically for negative and positive numbers: 5 + (-5) = 00000101 + 11111011 = 100000000, the leading carry is discarded, and the 8 remaining bits are 0, the correct answer. The most negative value is always -2^(N-1) (10000000 in 8-bit = -128), and the bit pattern for -1 is always all 1s.
Why isn't my fractional answer exact (e.g. 0.1)?
Most decimal fractions do not have a finite binary expansion. The algorithm multiplies the fractional part by 2 repeatedly and takes the integer part of each step as the next bit: 0.1 x 2 = 0.2 (bit 0), 0.2 x 2 = 0.4 (bit 0), 0.4 x 2 = 0.8 (bit 0), 0.8 x 2 = 1.6 (bit 1, remainder 0.6), and the pattern 0011 repeats forever. So 0.1 in binary is 0.0001100110011... and any finite truncation loses precision. This is exactly why JavaScript prints 0.1 + 0.2 = 0.30000000000000004: IEEE 754 doubles store 52 fractional bits, the closest representable value to 0.1 is slightly larger, and the rounding error survives the addition. The calculator's isExactConversion flag tells you whether your chosen bit width captured the value exactly.
Why can't 256 fit in 8 unsigned bits?
An N-bit unsigned field represents 0 through 2^N - 1, so 8 bits stop at 255 and 256 needs a ninth bit. What happens on assignment depends on the language and type: fixed-width arithmetic may wrap, while checked conversions may reject the value. Signed N-bit two's-complement ranges run from -2^(N-1) through 2^(N-1) - 1.
Why are hex and octal shown next to binary?
Hex and octal are compact rewrites of binary that group bits without changing the underlying value. Hex groups bits 4 at a time (16 = 2^4), so one hex digit always equals exactly 4 binary digits and a byte is always exactly 2 hex digits: 11111111 = 0xFF, 00010110 = 0x16. Octal groups bits 3 at a time (8 = 2^3), so 110010 = 0o62. Hex won in modern computing because bytes (8 bits) cut evenly into two hex digits but not into octal digits, which is why you see hex in color codes (#FF5733), MAC addresses, memory dumps, IPv6, JWT signatures, and SHA hashes. Octal still appears in Unix file permissions (chmod 755) and some legacy systems. Showing all three on the same result line saves a manual conversion when you need to drop the value into whichever notation your tool expects.

Related Calculators

More calculators in "Tech"

See all 98 calculators in "Tech"