Binary Calculator
Convert binary to decimal, hex and octal, or add, subtract, multiply, divide, AND, OR, XOR and shift binary numbers exactly, with two’s complement at 8 to 64 bits.
Result
In binary: 1011
Exact to any length: no rounding at any step.
- In decimal
- 11
- In hexadecimal
- B
- In octal
- 13
- Two’s complement at the chosen width
- 00001011
- That pattern read as a signed number
- 11
https://calcgallery.com/algebra-numbers/binary-calculator/
Results follow the mathematical operation and values shown. Check that you selected the intended operation, convention and dataset type before relying on the result. Read the full disclaimer
How to use the Binary Calculator
- Type a binary number, ones and zeros only, up to 64 digits.
- Choose an operation. To convert, leave it on Convert only; for arithmetic or a bitwise operation, type the second number too.
- Choose a bit width to see the result as a two’s complement pattern, and a pattern read back as a signed number.
Binary arithmetic
Binary addition carries whenever a column reaches two, exactly as decimal carries at ten: 1 + 1 is 10, and 1 + 1 + 1 is 11.
1011 (11) + 110 (6) ------ 10001 (17)
Division gives a whole-number quotient and a remainder, both in binary: 1011 ÷ 110 is 1, remainder 101, because 11 = 1 × 6 + 5.
Bitwise operations
AND keeps a 1 where both numbers have one; OR where either does; XOR where exactly one does. The answers keep the width of the longer number, so 1100 XOR 1010 reads 0110 rather than 110. Shifting left one place doubles a number, and shifting right halves it, dropping any remainder.
With your numbers
- Each binary digit is worth twice the one to its right: 1011 = 8 + 0 + 2 + 1 = 11.
Quick reference
Exact to any length: no rounding at any step.
| Example | In binary |
|---|---|
| 1011 to decimal | 1011 |
| 1011 + 110 | 10001 |
| 1011 − 110 | 101 |
| 1011 × 110 | 1000010 |
| 1100 AND 1010 | 1000 |
| 1100 XOR 1010 | 0110 |
| 0 − 101, 8 bits | −101 |
| 11111011 as signed 8 bits | 11111011 |
| Sixty-four ones | 1111111111111111111111111111111111111111111111111111111111111111 |
Common questions about the Binary Calculator
- How do I convert binary to decimal?
- Each digit is worth twice the one to its right, starting from 1 at the right-hand end. For 1011, that is 8 + 0 + 2 + 1 = 11. Hexadecimal groups the digits in fours from the right, so 1011 is B, and octal in threes, so 1 011 is 13.
- What is two’s complement?
- The way computers store negative whole numbers. In 8 bits, −5 is 256 − 5 = 251, which is 11111011. The top bit then counts as −128 instead of +128, so the same pattern reads as −5 when the number is signed and 251 when it is not. The width matters: in 16 bits, −5 is 1111111111111011.
- Why does the answer need a bit width?
- Because a negative number has no binary pattern until you say how many bits hold it, and NOT flips every bit, which for an unbounded number would be infinitely many. The width sets both. A result too large for the width, even as a signed number, is flagged rather than silently cut short.
- How is this different from a programming language’s bitwise operators?
- JavaScript, for one, converts numbers to 32 bits before AND, OR and XOR, and ordinary numbers lose digits above 2⁵³. This page works with exact whole numbers of any length, so a 64-bit value keeps every bit.