How to Convert Between Binary, Decimal, and Hexadecimal
Convert binary, decimal, and hexadecimal by hand, understand positional notation, and use JavaScript safely for very large integers.
Binary 101101 is decimal 45 and hexadecimal 2D. Expand each digit by its positional value, or group binary digits into four-bit chunks. The Number Base Converter checks the arithmetic and converts integers between bases 2 and 36.
Positional notation: what a base means
In base b, each position represents a power of b. Decimal uses 0–9, binary uses 0 and 1, and hexadecimal uses 0–9 plus A–F, where A is 10 and F is 15. Thus 2D₁₆ = 2×16¹ + 13×16⁰ = 45₁₀.
Convert binary, decimal, and hex by hand
Binary to decimal
For 101101₂, add the powers of two under the 1 digits: 32 + 8 + 4 + 1 = 45.
Decimal to binary
Repeatedly divide by 2, record each remainder, and read the remainders upward. That converts 45₁₀ to 101101₂.
Binary to hexadecimal
Pad on the left and split into groups of four: 101101₂ → 0010 1101₂ → 2D₁₆. One hex digit is four bits because 16 = 2⁴.
How the converter handles input
The tool accepts an optional leading sign. In auto-detect mode, 0b, 0o, and 0x select binary, octal, and hexadecimal; otherwise input is decimal. Spaces and underscores between digits are ignored, and custom bases from 2 through 36 are supported.
Negative numbers and two’s complement
A mathematical negative value keeps its minus sign. Hardware commonly stores a signed integer in a fixed width using two’s complement: for w bits, a negative value is represented by 2w plus that value. Thus -1 in 8 bits is 11111111. The tool offers signed 8-, 16-, 32-, and 64-bit widths and reports values that do not fit.
JavaScript: radix, parseInt, and BigInt
For safe integers, parseInt(text, radix) reads a string and number.toString(radix) writes a number. Pass the radix explicitly. For values beyond Number.MAX_SAFE_INTEGER (2⁵³ − 1), use BigInt; BigInt("18446744073709551616").toString(16) returns 10000000000000000. A plain BigInt("101101") is decimal, not binary.
Step-by-step checklist
1.Identify the source base
Binary is base 2, decimal is base 10, and hexadecimal is base 16. A 0b, 0o, or 0x prefix can identify a value when the converter is set to auto-detect.
2.Expand the digits by place value
Multiply each digit by the source base raised to its position, counting from zero at the rightmost digit, then add the results.
3.Convert the decimal value back by repeated division
Divide by the destination base, record each remainder, and read the remainders from last to first. For binary and hexadecimal, grouping bits is often faster.
4.Check the result in the converter
Enter the integer in the Number Base Converter and compare its binary, decimal, hexadecimal, and optional two’s-complement outputs.
// Frequently Asked Questions
How do I convert binary 101101 to decimal?
Expand the place values: 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 45. Therefore, 101101₂ = 45₁₀.
Why is one hexadecimal digit four bits?
Hexadecimal has 16 possible digits, and 16 equals 2⁴. Each hex digit therefore maps exactly to a four-bit group.
Can JavaScript convert integers larger than 2^53 exactly?
Use BigInt for integers beyond Number.MAX_SAFE_INTEGER. The Number Base Converter uses BigInt internally, so it preserves arbitrary-size integer digits instead of rounding them through Number.
How are negative binary numbers represented?
A minus sign is a mathematical negative value. In a fixed-width computer representation, two’s complement uses 2^width plus the negative value; the converter supports signed 8-, 16-, 32-, and 64-bit widths and reports values that do not fit.