Binary Calculator - Operations
Add, subtract, AND, OR, and XOR two binary numbers, with the decimal equivalent shown for both operands and the result.
Binary Calculator - Operations
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: Binary: base-2 number system (0 and 1)
Worked example — 1010 + 1100 = 10110 (22 in decimal)
Formula
Binary: base-2 number system (0 and 1)
Perform arithmetic and bitwise operations on binary numbers. Convert between binary and decimal.
Worked Examples
Example 1: Binary addition
Problem:1010 + 1100
Solution:1010 is 8 + 2 = 10 and 1100 is 8 + 4 = 12. Add column by column from the right: 0+0=0; 1+0=1; 0+1=1; 1+1=10, so write 0 and carry 1. The carry out of the top column becomes the leading 1: 10110. Check in decimal: 10 + 12 = 22, and 10110 = 16 + 4 + 2 = 22.
Result:1010 + 1100 = 10110 (22 in decimal)
Example 2: Bitwise XOR
Problem:1010 XOR 1100
Solution:XOR outputs 1 only where the two bits differ: 1010 1100 ---- 0110 Bit 3: 1 vs 1 same, 0. Bit 2: 0 vs 1 differ, 1. Bit 1: 1 vs 0 differ, 1. Bit 0: 0 vs 0 same, 0. 0110 = 4 + 2 = 6, and 10 XOR 12 = 6. Two bits differ, so the Hamming distance between 10 and 12 is 2.
Result:1010 XOR 1100 = 0110 (6 in decimal), Hamming distance 2
Frequently Asked Questions
How does binary addition work?
Same as decimal but carry at 2 instead of 10. 0+0=0, 0+1=1, 1+1=10 (carry 1), 1+1+1=11 (carry 1).
What are bitwise AND, OR, and XOR operations?
AND outputs 1 only when both bits are 1. OR outputs 1 when at least one bit is 1. XOR outputs 1 only when bits differ. These are the building blocks of all digital logic in processors.
How do I convert binary to decimal?
Multiply each bit by its positional power of 2 and sum the results. For 1101: (1×8)+(1×4)+(0×2)+(1×1) = 8+4+0+1 = 13. Binary Calculator - Operations shows the decimal equivalent automatically.
When would I use binary arithmetic?
Binary operations are essential for embedded systems programming, network mask calculations (subnetting), bit flags in game engines, cryptography, and understanding how CPUs perform arithmetic at the hardware level.
What is two's complement and how does it represent negative numbers?
Two's complement encodes a negative value by inverting every bit of the magnitude and adding 1, so in eight bits -5 is the complement of 00000101, which is 11111010, plus 1, giving 11111011. The most significant bit then acts as a sign flag, and an eight-bit register covers -128 to 127. The advantage is that ordinary binary addition hardware handles signed and unsigned arithmetic identically, with no separate subtract circuit needed.
What does a minus sign in front of the binary result mean?
When a subtraction underflows, Binary Calculator - Operations prints the magnitude in binary with a leading minus sign rather than expanding the value into a 32-bit two's complement pattern. So 101 minus 111 is shown as -10, meaning decimal -2, not as a string of ones. That is easier to read, but it does not match what a fixed-width register would actually contain, so convert to two's complement yourself when you are reasoning about hardware.
How do bit shifts relate to multiplication and division?
Shifting a binary number one place left appends a zero and doubles its value, exactly as appending a zero in decimal multiplies by ten. Shifting right by one discards the least significant bit and halves the value, rounding towards zero for non-negative numbers. So 1011 (11) shifted left becomes 10110 (22), and shifted right becomes 101 (5). Compilers routinely replace multiplication or division by a power of two with a shift, because shifting is far cheaper.
How do I convert between binary and hexadecimal quickly?
Group the bits into fours starting from the right, padding the leftmost group with zeros, then replace each nibble with its hex digit. So 11011010 splits into 1101 and 1010, which are D and A, giving 0xDA, or 218 in decimal. The reverse direction is just as mechanical: expand each hex digit into its four-bit pattern. This works because 16 is 2 to the fourth power, which is exactly why hex is the preferred shorthand for binary data.
Why do the bitwise results here stay within 32 bits?
JavaScript, which runs Binary Calculator - Operations, converts operands to signed 32-bit integers before applying AND, OR and XOR, then converts the result back. Values needing more than 32 bits wrap around, so a bit pattern longer than 32 digits will not behave as written. Ordinary addition and subtraction are done in floating point and are exact well past that range, which is why the arithmetic and the bitwise operations have different practical limits.
What makes XOR so useful in practice?
XOR outputs 1 only when its two input bits differ, which makes it its own inverse: applying the same mask twice returns the original value, since a XOR b XOR b equals a. That property underlies simple stream ciphers, the classic register swap without a temporary variable, and toggling individual flag bits. XOR across all the bits of a word also yields the parity bit used in memory and serial link error detection.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator · Editorial policy
Related Calculators
🧮Binary Addition Calculator
Calculate binary addition with inputs, formulas, and instant results.
🧮Binary Division Calculator
Calculate binary division with inputs, formulas, and instant results.
🧮Binary Fraction Converter
Calculate binary fraction converter with inputs, formulas, and instant results.
🧮Binary Multiplication Calculator
Calculate binary multiplication with inputs, formulas, and instant results.
🧮Binary Subtraction Calculator
Calculate binary subtraction with inputs, formulas, and instant results.
🧮Binary Hex Decimal Octal Converter
Calculate binary hex decimal octal converter with inputs, formulas, and instant results.
🧮Binary to Decimal Converter
Calculate binary to decimal converter with inputs, formulas, and instant results.
🧮Set Operations Calculator
Perform union, intersection, difference, and complement operations on sets.