Decimal to Binary Converter
Convert standard base-10 decimal numbers into binary, octal, and hexadecimal bases.
One number, three alternate bases
Decimal notation uses powers of ten, but software frequently displays values in base 2, base 8, and base 16. Binary exposes individual bits, octal compresses each three-bit group, and hexadecimal compresses each four-bit group. Entering a decimal number here generates all three representations at once, each with its own copy button.
For decimal 255, the panels show binary 11111111, octal 377, and hexadecimal FF. These strings describe the same numeric value without prefixes or fixed-width padding.
Understanding place values
The binary result is a sum of powers of two. 13 becomes 1101 because 8 + 4 + 0 + 1 equals 13. Octal 15 expresses 1×8 + 5. Hexadecimal D uses the digit D for decimal 13. The converter delegates this positional conversion to JavaScript’s number formatting for radix 2, 8, and 16, then uppercases hex letters.
This is useful for checking a bit mask, translating a status code, preparing an integer literal, or comparing values shown by tools using different bases. It does not add language syntax such as 0b, 0o, or 0x; add those prefixes only where the target language expects them.
A bit-mask workflow
Suppose documentation says a permission value is decimal 45. Enter it and inspect binary 101101. Reading from the least significant bit on the right, set positions are 0, 2, 3, and 5. Hexadecimal 2D is a compact literal suitable for logs or source code.
Before using the result, determine the required width. An 8-bit register usually displays the same value as 00101101, but the page outputs 101101 because leading zeros have no numeric significance. For a 16-bit field, pad to 0000000000101101. Width belongs to the data type or protocol, not the value itself.
Copy a panel independently so binary, octal, and hex cannot be confused. Include a prefix or label in documentation when the surrounding context does not establish the base.
Integers are the safest input
The input uses a numeric browser field and JavaScript Number. Ordinary nonnegative integers are the clearest case. Negative integers are accepted by number conversion and format with a leading minus sign, such as -1010; this is sign-and-magnitude text, not a fixed-width two’s-complement representation.
Decimal fractions are also accepted, and JavaScript can emit a radix point with an approximate fractional expansion. Binary fractions often repeat because many decimal fractions cannot be represented exactly in base 2. The result may be long and reflect floating-point approximation. For protocol words and integer programming tasks, enter an integer.
Scientific notation may be accepted by the numeric control or JavaScript conversion, depending on browser interaction. The displayed base strings represent the resulting Number, not the original decimal spelling.
Two’s complement is a separate decision
Developers often ask for a decimal to binary converter when they actually need a signed machine encoding. Decimal -1 could be 11111111 in 8-bit two’s complement, 1111111111111111 in 16-bit form, or a wider sequence. Without a width, there is no unique answer. This tool returns -1 in each radix notation rather than selecting a machine width.
To encode a signed integer, choose the bit width and compute its unsigned residue modulo 2 to that width. Then pad the binary or hexadecimal result. Also confirm overflow rules and endianness if bytes will be stored or transmitted. Those concerns are outside this page’s conversion.
Precision and the safe integer boundary
JavaScript numbers use IEEE 754 double precision. Integers are exact only through Number.MAX_SAFE_INTEGER, 9,007,199,254,740,991. Beyond that, adjacent integers cannot always be distinguished. A large account ID, 64-bit database key, blockchain quantity, or bit mask may be rounded before base conversion, producing a plausible but wrong string.
For exact large integers, use a BigInt-based utility or language library that reads the decimal digits as an integer rather than as a floating-point Number. Never verify a 64-bit constant solely through this converter unless it falls within the safe range.
Octal and hex in real systems
Octal remains visible in Unix permission modes: decimal 493 corresponds to octal 755. Be careful, however, because permission notation typically interprets the entered text as octal from the beginning. This page accepts decimal input only; entering 755 means decimal 755 and yields a different octal value.
Hexadecimal appears in memory addresses, Unicode notation, network protocol fields, masks, and RGB channels. If a specification says 0xFF, the decimal input is 255, not the text FF. The page does not parse alternate-base input or convert back to decimal.
Binary is valuable for flag layouts. Add leading zeros to match the documented register width and group long results into nibbles or bytes manually for reading. The copy output itself contains no separators.
Empty and invalid states
When the input is empty or cannot be converted to a number, each output panel shows a dash. There is no detailed validation message. A browser numeric field generally prevents arbitrary letters, though pasted or transient forms can vary by browser.
Values such as infinity or not-a-number are not meaningful base conversions and should not be used. If output contains a radix point, exponent-like notation, or an unexpectedly rounded tail, reassess whether an integer and exact-integer tool is required.
Checking a conversion manually
For binary, repeatedly divide a positive integer by two and read remainders in reverse, or sum powers corresponding to set bits. For hex, group the binary result in sets of four from the right. 101101 pads to 0010 1101, giving hex digits 2 and D. For octal, group into threes: 101 101 gives 55, which is decimal 45.
Manual grouping is an effective review for short security-sensitive constants. It also reveals when missing leading zeros are merely presentation rather than a changed value.
Turning output into source literals
Most languages distinguish a number’s value from its source notation. JavaScript and Python accept forms such as 0b101101, 0o55, and 0x2D; other languages vary in octal syntax, suffixes, width, and signedness. The copied output intentionally omits prefixes, so add one only after checking the language grammar.
A literal can also be valid but inferred with an unsuitable type. In C, Rust, or embedded code, ensure the value fits the declared unsigned or signed width. In shell scripts, beware that a leading zero may trigger octal interpretation. In JSON, alternate-base number literals are not valid at all; store decimal 45 as a number or "2D" as a labeled string. Conversion does not establish how a parser will interpret pasted text.
Common confusion and fixes
If binary has fewer digits than expected, pad it to the required word width. If negative output begins with -, the tool is showing mathematical notation, not two’s complement. If a large value is off by one or more, it likely exceeded safe integer precision. If entering FF is impossible, convert it to decimal first or use a bidirectional base converter.
If octal permissions look wrong, remember the input label says Decimal Number. Enter decimal 493 to obtain octal 755. If a fractional result is surprisingly long, that is binary floating-point behavior; use rational arithmetic when exact fractions matter.
Conversion questions
Does the binary output include leading zeros?
No. It uses the shortest standard representation. Add padding according to an 8-, 16-, 32-, or other bit-width requirement.
Can it convert hex back to decimal?
No. The single input is interpreted as decimal and the three panels are outputs.
Are negative values two’s complement?
No. They are formatted with a minus sign. Two’s complement requires a chosen bit width.
Why is a 64-bit integer inaccurate?
The implementation uses JavaScript Number, whose exact integer range is smaller than the full unsigned or signed 64-bit range.
Can I copy only hexadecimal?
Yes. Each output card has its own copy control and feedback state.
Is decimal 10 the same as hex 10?
No. Decimal 10 is hexadecimal A; hexadecimal 10 is decimal 16. Always identify the source base.