Binary Calculator
Perform exact binary arithmetic and bitwise logic operations, including addition, subtraction, multiplication, division, AND, OR, XOR, NOT, and bit shifts with real-time multi-base conversions.
Carry: 0 0 0 0 0 0 0 0
A: 0 0 1 0 1 0 1 1 (43)
+ B: 0 0 0 1 0 0 1 0 (18)
-----------------------
Sum: 0 0 1 1 1 1 0 1 (61)
How to Use This Binary Calculator
- Select Your Operation: Choose from basic arithmetic (Add, Subtract, Multiply, Divide) or bitwise operations (AND, OR, XOR, NOT, Shift Left, Shift Right).
- Enter Binary Digits: Type or paste binary strings composed of 0s and 1s into Operands A and B, or click the on-screen 0 and 1 keypad buttons. Spaces and underscores are automatically handled.
- Toggle Bits Visually: Click any cell in the 8-bit visual register to flip individual bits between 0 and 1 with real-time recalculation.
- Review Instant Multi-Base Conversions: Examine the synchronized output showing exact binary (with 4-bit nibble formatting), decimal (base 10), hexadecimal (base 16), and octal (base 8).
- Inspect Column Work: View the detailed bit-by-bit step visualization showing carry bits, operand alignment, and truth table results.
Computer Science Architecture & Binary Mechanics
Binary arithmetic forms the foundation of digital logic design, microprocessor execution units, and network protocols:
Base-2 Positional Numbering
Unlike the decimal system (base 10) which uses powers of 10, the binary system (base 2) assigns values to positional columns according to ascending powers of two (2⁰ = 1, 2¹ = 2, 2² = 4, 2³ = 8, 2⁴ = 16, 2⁵ = 32, 2⁶ = 64, 2⁷ = 128). An 8-bit byte composed of 10101011 represents 128 + 32 + 8 + 2 + 1 = 171 in decimal notation.
Full Adders and Carry Propagation
In hardware arithmetic logic units (ALUs), binary addition uses full adder circuits. Each bit position computes two distinct outputs: the sum bit ($S = A \oplus B \oplus C_{in}$) and the carry bit ($C_{out} = (A \cdot B) + (C_{in} \cdot (A \oplus B))$). When two 1s are added, the sum produces 0 with a carry of 1 to the next higher power column (1 + 1 = 10₂).
Bitwise Logic in Systems Programming
Bitwise operations manipulate individual bits directly within CPU registers. AND masks specific bits to zero; OR forces target bits to one; XOR toggles bits and detects bit differences (commonly used in cryptography, error checking, and graphics rasterization); bit shifts rapidly multiply or divide integers by powers of two without invoking expensive hardware division cycles.
Quick Reference: Powers of Two & Hexadecimal Equivalents
| Power of 2 | Binary Pattern | Decimal (Base 10) | Hexadecimal (Base 16) | Common Architecture Unit |
|---|---|---|---|---|
| 2⁰ | 0000 0001 | 1 | 0x01 | 1 Bit (LSB) |
| 2¹ | 0000 0010 | 2 | 0x02 | 2 Bits |
| 2² | 0000 0100 | 4 | 0x04 | 1 Nibble (half-byte) |
| 2³ | 0000 1000 | 8 | 0x08 | Octet Boundary |
| 2⁴ | 0001 0000 | 16 | 0x10 | Hex Digit Base |
| 2⁵ | 0010 0000 | 32 | 0x20 | ASCII Space Offset |
| 2⁶ | 0100 0000 | 64 | 0x40 | Cache Line Alignment |
| 2⁷ | 1000 0000 | 128 | 0x80 | 8-Bit Sign Bit (MSB) |
| 2⁸ | 0001 0000 0000 | 256 | 0x100 | 1 Byte Capacity (0-255) |
| 2¹⁰ | 0100 0000 0000 | 1,024 | 0x400 | 1 Kibibyte (KiB) |
| 2¹⁶ | 0001 0000 0000 0000 0000 | 65,536 | 0x10000 | 16-Bit Word Capacity |
Binary Arithmetic Formulas & Logic Gates
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10₂ (0 with carry of 1)
1 + 1 + 1 = 11₂ (1 with carry of 1)
2. Binary Subtraction Rules (Borrow):
0 − 0 = 0
1 − 0 = 1
1 − 1 = 0
0 − 1 = 1 (with borrow of 1 from next column)
3. Primary Bitwise Operations:
AND (&): A · B = 1 only if A = 1 and B = 1
OR (|): A + B = 0 only if A = 0 and B = 0
XOR (^): A ⊕ B = 1 if A ≠ B (parity detector)
NOT (~): ¬A = 1 if A = 0, and 0 if A = 1
Step-by-Step Working Example: Binary Addition
Consider calculating the sum of two binary numbers: 1011₂ (11 in decimal) and 0110₂ (6 in decimal):
- Operand A: 1011₂ (Decimal: 11)
- Operand B: 0110₂ (Decimal: 6)
Step 1: Column Bit Additions (Right to Left):
• Column 0 (2⁰): 1 + 0 = 1 (Carry: 0)
• Column 1 (2¹): 1 + 1 + 0 = 0 (Carry: 1)
• Column 2 (2²): 0 + 1 + 1 = 0 (Carry: 1)
• Column 3 (2³): 1 + 0 + 1 = 0 (Carry: 1)
• Column 4 (2⁴): Carry 1 drops down to yield 1
Step 2: Collect Sum Bits:
The resulting binary string is 10001₂.
Step 3: Verification via Decimal Conversion:
10001₂ = (1 × 2⁴) + (0 × 2³) + (0 × 2²) + (0 × 2¹) + (1 × 2⁰) = 16 + 1 = 17.
Because 11 + 6 = 17, the calculation is verified exact.
Important Technical Terms
- Bit: The fundamental atomic unit of information in digital computing, representing binary state 0 or 1.
- Nibble: A grouping of four consecutive binary bits, exactly corresponding to one hexadecimal character (0 to F).
- Byte (Octet): A sequence of eight contiguous bits, representing values from 0 to 255 unsigned, or −128 to 127 signed.
- Most Significant Bit (MSB): The leftmost bit carrying the highest numeric value or indicating sign in two's complement format.
- Least Significant Bit (LSB): The rightmost bit carrying the value 2⁰ (1), dictating whether an integer is even or odd.
- Hamming Weight (Population Count): The total number of active non-zero bits (1s) contained in a binary string.
- Two's Complement: The standard mathematical method used by modern computer processors to encode signed negative integers.