Binary calculator
Type two numbers in binary (0s and 1s) and pick the operation. Option: a fixed width (8, 16, 32 or 64 bits) read as signed or unsigned.
Result
0001 0001Result in binary
- In decimal
- 17
- In hexadecimal
- 11
- Bits read as unsigned
- 17
- Bits read as signed (two’s complement)
- 17
- Convention: 8-bit unsigned. Every value is zero or positive.
Inputs
- First binary number
- 1011
- Operation
- + (add)
- Second binary number
- 0110
- Width
- 8 bits
- Read the bits as
- Unsigned
How it is calculated
Each binary digit is a power of 2: 1011 = 8 + 0 + 2 + 1 = 11.
Result
Result in binary
- In decimal
- 17
- In hexadecimal
- 11
- Bits read as unsigned
- 17
How it is calculated
- Each binary digit is a power of 2: 1011 = 8 + 0 + 2 + 1 = 11.
- We compute on exact whole numbers, then write the result back in base 2.
- Division: whole quotient (rounded toward zero) and remainder.
- With a fixed width, the result is cut to N bits, then read as signed and as unsigned.
Example
1011 + 0110 on 8 unsigned bits: 11 + 6 = 17, that is 0001 0001 (hex 11).
Good to know
- Up to 4,096 binary digits per number with a free width.
- With a fixed width, numbers are typed without a minus sign: type the bit pattern.
When to use it
- Check a binary addition or a logical AND for a computer science or electronics class.
- See what an overflow does on 8, 16 or 32 bits, as signed and unsigned values.
- For calculations written in base 16 (addresses, colours), the Hexadecimal calculator saves converting by hand.
Frequently asked questions
What is two’s complement?
It is the usual way to write negative integers in binary. On 8 bits, the leftmost bit is worth −128, so 1111 1111 is −1 as signed and 255 as unsigned.
What values fit in 8 bits?
From 0 to 255 unsigned, and from −128 to 127 signed. On 16 bits, it is 0 to 65,535 or −32,768 to 32,767.
What happens on overflow?
Only the rightmost N bits are kept, as in a processor. The tool shows a warning so you can see what was lost.
What is XOR used for?
XOR gives 1 where the two bits differ. It is used to flip chosen bits or to compare two patterns.