Writing numbers in binary
Every whole number can be written as a sum of distinct powers of two, and that sum is its binary form. 42 = 32 + 8 + 2, so in binary it has ones in the 32, 8 and 2 positions: 101010. Binary is how computers store integers, so the conversion shows exactly which bits a value sets, which is what you need for bit flags, masks and low-level protocols.
Grouping bits in fours (nibbles) makes long values readable and lines them up with hexadecimal: each group of four bits is one hex digit.
Worked example
Divide by 2 and keep the remainders: 42 → 21 r0 → 10 r1 → 5 r0 → 2 r1 → 1 r0 → 0 r1. Reading the remainders from last to first gives 101010. Grouped: 0010 1010, which is 2A in hex.
Bit length
The table shows how many bits the number needs. 255 needs 8, 256 needs 9. That tells you the smallest integer type that can hold the value: 8 bits for 0–255, 16 for up to 65,535, 32 for up to about 4.3 billion.
How this works
The page parses your decimal input into an exact big integer, then writes it in base 2. That is the same as dividing by two repeatedly and reading the remainders backwards, but it stays exact for numbers with hundreds of digits. With grouping on, the bits are padded on the left to a multiple of four and split into nibbles. The table repeats the value in octal, decimal and hexadecimal and gives its length in bits. A minus sign is kept as a sign; two's complement is not applied. Each line converts separately.
Frequently asked
How do I convert decimal to binary by hand?
Divide by 2 repeatedly and write down the remainders; read them from the last to the first. 13 → 1101.
Why group bits in fours?
Each group of four bits is exactly one hexadecimal digit, which makes long values easy to read and check.
How are negative numbers shown?
With a minus sign. Two's complement depends on the integer width, so it is not applied.
Can I convert decimals like 0.5?
Not here; the page converts whole numbers only.
Sources
- ECMA-262 — ECMAScript Language Specification
- ISO 80000-1:2022 — Quantities and units — Part 1: General
- Wikipedia — Binary number
Reviewed Oct 17, 2026 · test vectors fixtures/dev/decimal-to-binary/