Decimal to Binary Converter: Exact, Any Length
Convert decimal to binary exactly, for numbers of any length, with optional 4 or 8-bit grouping and two's complement for negative numbers. Runs in your browser. Nothing is uploaded.
About the Decimal to Binary Converter
This page opens the Number Base Converter with decimal as the input and binary highlighted at the top of the results. Type any whole number, positive or negative and of any length, and you get its exact binary form, with octal, hexadecimal, BCD, Gray code and two's complement alongside. Each result has a Copy button. Everything runs in your browser, and nothing is uploaded.
How to use it
Steps
- Type or paste the decimal number. Spaces and underscores used as thousands separators are ignored, so
1 000 000and1_000_000both work. - Read the binary result at the top. Choose Groups of 4 or Groups of 8 to split it into nibbles or bytes for easier reading.
- For a negative number, the binary row shows a minus sign followed by the magnitude, such as −101 for −5. To see how a computer stores it, read the Two's complement row and pick a width of 8, 16, 32 or 64 bits.
How decimal becomes binary
Repeated division
Divide the number by 2 and write down the remainder, then divide the quotient by 2 again, until the quotient is 0. The remainders read from last to first are the binary digits. For 45: 45 ÷ 2 = 22 remainder 1, 22 ÷ 2 = 11 r 0, 11 ÷ 2 = 5 r 1, 5 ÷ 2 = 2 r 1, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1. Reading upwards gives 101101.
Exact for any size
The page uses arbitrary-precision integers, so numbers larger than 2 to the power of 53, where an ordinary JavaScript number starts to lose digits, still convert exactly. You can paste a 40-digit value and get every bit right. Inputs of up to 10,000 digits are accepted.
Negative numbers in two's complement
Processors store a negative number −n in a fixed width as 2^width − n. At 8 bits, −1 is 11111111, −5 is 11111011 and −128 is 10000000. The range at a width of w bits is −2^(w−1) to 2^(w−1) − 1, so 8 bits hold −128 to 127. A number outside the range is reported rather than wrapped.
Common values
- 10 is
1010, 100 is1100100and 255 is11111111. - 1,024 is a 1 followed by ten zeros.
- 65,535 is sixteen 1s, the largest unsigned 16-bit value.
Privacy
The conversion is done in your browser by code on this page. Your numbers are never sent anywhere, and nothing is stored once the tab is closed.
Related tools
To read binary back, use Binary to Decimal. For hexadecimal output, use Decimal to Hex. To add, subtract, AND, OR or shift the result, open the Binary Calculator. To encode text characters rather than numbers as binary, use Text to Binary.
Open-source credits
- The converter is written for this site and uses no third-party library. Arithmetic uses the browser's built-in
BigInt, specified in ECMA-262, the ECMAScript language specification. - Two's complement follows the signed integer representation required by ISO/IEC 9899:2024 (C23).