How to use the binary calculator
- Choose a mode. “Convert bases” turns a number in base 2, 8, 10 or 16 into the other three. “Arithmetic” adds, subtracts, multiplies or divides two non-negative whole numbers in the base you choose.
- Enter a non-negative integer. Binary digits can only be 0 or 1, octal 0–7, decimal 0–9, and hexadecimal 0–9 and A–F. Spaces, commas and prefixes such as 0b, 0o or 0x are allowed. This version does not accept fractions or negative numbers.
- Read the four bases and the steps. The large figure is the decimal value. The cards show the same number in binary, octal and hexadecimal, with the positional expansion underneath.
The calculator opens on 1011 in base 2. As in OpenStax’s Contemporary Mathematics, section 4.3, Example 4.17, 1011₂ = 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰ = 11 in decimal.
Place value in another base
In any positional system, the value of a digit depends on its place. In base b, the places are the powers of b, and a numeral dₙ…d₁d₀ means
Base 2 (binary) uses the digits 0 and 1, and the places are 1, 2, 4, 8, 16, …. Base 8 (octal) uses 0–7. Base 16 (hexadecimal) uses 0–9 and A–F, with A = 10 through F = 15. The familiar decimal system is the same idea with b = 10, as in OpenStax Contemporary Mathematics, section 4.1.
Example 4.17 in section 4.3 converts 1011₂ to decimal that way: 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1 = 11. Your Turn 4.17, the follow-up exercise, asks for 11011₂, which is 16 + 8 + 0 + 2 + 1 = 27. Load “11011₂” to see the steps.
Converting from decimal by repeated division
To write a decimal number in another base, divide by that base, record the remainder, and repeat with the quotient until the quotient is 0. The remainders, read from last to first, are the digits in the new base. Section 4.3 describes this method and uses it for several bases.
For 11 in decimal to binary: 11 ÷ 2 = 5 remainder 1, 5 ÷ 2 = 2 remainder 1, 2 ÷ 2 = 1 remainder 0, 1 ÷ 2 = 0 remainder 1. Reading the remainders upward gives 1011₂, which matches the example in the other direction.
The same remainders are what a modulo calculation would give: each remainder is the decimal number mod 2, then the quotient, and so on. Long strings of those divisions can also be laid out with the long division calculator.
Binary, octal and hexadecimal grouping
Because 8 = 2³ and 16 = 2⁴, you can move between binary and octal or hexadecimal by grouping bits instead of converting through decimal. From the right, every three binary digits make one octal digit, and every four make one hexadecimal digit. The other way, each octal digit becomes three bits and each hexadecimal digit becomes four. So 11111111₂ = 377₈ = FF₁₆ = 255 in decimal.
Arithmetic in these bases
The “Arithmetic” mode adds, subtracts, multiplies or divides two non-negative integers in the base you choose, and also reports the result in the other three bases. Subtraction requires the first number to be at least the second, because this version stays with non-negative results. Division gives a whole-number quotient and a remainder, so 1011₂ ÷ 10₂ is 101₂ remainder 1₂, or 11 ÷ 2 = 5 remainder 1 in decimal.
Negative numbers, binary complements and fractions are outside the scope of this version.
Sources & assumptions
How this calculator gets its numbers. Full method: our methodology.
- A numeral dₙ…d₀ in base b has value dₙbⁿ + ⋯ + d₁b + d₀. Bases 2, 8, 10 and 16 use the usual digits (hexadecimal A–F for 10–15).
- Decimal to another base uses repeated division by the base; the remainders, read last to first, are the new digits.
- This version handles non-negative integers only. Arithmetic in a chosen base is done exactly, and subtraction requires a non-negative result.
Sources
- OpenStax (Rice University), Contemporary Mathematics, 4.1 Hindu-Arabic Positional System. Place value based on powers of the base, and expanded form (for example 738 = 7×10² + 3×10¹ + 8×10⁰).
- OpenStax (Rice University), Contemporary Mathematics, 4.3 Converting with Base Systems. Converting another base to base 10 by place value (Example 4.17: 1011₂ = 11) and converting from base 10 by repeated division, remainders read last to first.
Last reviewed . For a single remainder a mod n, use the modulo calculator.
Frequently asked questions
What is 1011 in binary as a decimal number?
1011₂ = 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal.
How do I convert a decimal number to binary?
Divide the number by 2, record the remainder, and repeat with the quotient until it is 0. The remainders, read from last to first, are the binary digits. 11 becomes 1011₂.
What digits can I use in each base?
Binary (base 2): 0 and 1. Octal (base 8): 0–7. Decimal (base 10): 0–9. Hexadecimal (base 16): 0–9 and A–F, where A is 10 and F is 15.
Does this calculator handle negative numbers or fractions?
No. This version converts and calculates with non-negative whole numbers only.
How do I convert between binary and hexadecimal quickly?
Group the binary digits in fours from the right; each group is one hexadecimal digit. In the other direction, replace each hexadecimal digit with four binary digits.
What is the difference between this tool and the modulo calculator?
The modulo calculator finds a single remainder a mod n. Converting from decimal to another base repeats that remainder step until the quotient is 0.