Binary Calculator
Binary calculator for any size integer: add, subtract, multiply, divide, AND, OR, XOR, NOT and bit shifts, with results in binary, hex, decimal and octal.
Choose 8/16/32/64-bit to see two's complement patterns (useful for NOT and negative numbers).
Results
- Arbitrary-precision integers (BigInt). Division truncates toward zero. With a bit width, results are wrapped and shown as two's complement.
What is Binary Calculator?
Performs arithmetic and bitwise operations on two binary numbers of any length and shows the result in binary (grouped in 4-bit blocks), hexadecimal, decimal and octal. An optional 8/16/32/64-bit width shows two's-complement results.
How to use Binary Calculator
- Enter Number A in binary (an optional
0bprefix, spaces and underscores are allowed). - Choose the Operation: +, −, ×, ÷, mod, AND, OR, XOR, NOT, << or >>.
- Enter Number B (not needed for NOT) and optionally a Bit width.
Example
1010 + 0110
1 0000 (hex 10, decimal 16, octal 20)
When to use Binary Calculator
Use it for digital-logic homework, bit masks, flags and checking low-level code. To convert a single number between bases without arithmetic, the Number Base Converter is simpler.
How Binary Calculator works
Inputs are parsed into JavaScript BigInt values, so there is no 32- or 53-bit limit. Division truncates toward zero and mod keeps the sign of A, like most programming languages. NOT is ~A = −A − 1. With a bit width w, the result is wrapped with BigInt.asUintN(w) and shown as an unsigned pattern, and the signed (two's complement) decimal value is also given. Shift amounts are limited to 0–4096 bits.
Common Use Cases
- Adding binary numbers and checking carries
- Computing masks with AND/OR/XOR
- Seeing an 8-bit NOT in two's complement
- Shifting values left or right
FAQs
How are negative numbers shown?
Without a bit width they are shown with a minus sign (−101). With a width they are shown as two's-complement bit patterns plus the signed decimal value.
Why does NOT 101 give a negative number?
With unlimited width, NOT flips infinitely many leading zeros, giving −6. Pick 8-bit to see 1111 1010 (250 unsigned, −6 signed).
Is there a size limit?
No practical one: BigInt handles hundreds of digits. Only shift amounts are capped at 4096 to keep results reasonable.