Skip to main content

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.

Binary Operands
8 bits | Dec: 43
Interactive 8-Bit Register (Value A) Click bits to toggle
8 bits | Dec: 18
Common Presets
Calculation Results
Binary Sum (A + B) 6 Bits Output
0011 1101
Decimal: 61 | Hex: 0x3D | Octal: 0o75
Decimal (Unsigned)
61
Hexadecimal
0x3D
Octal
0o75
Active High Bits (Weight)
5 bits
Bit-by-Bit Column Alignment
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

  1. Select Your Operation: Choose from basic arithmetic (Add, Subtract, Multiply, Divide) or bitwise operations (AND, OR, XOR, NOT, Shift Left, Shift Right).
  2. 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.
  3. Toggle Bits Visually: Click any cell in the 8-bit visual register to flip individual bits between 0 and 1 with real-time recalculation.
  4. 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).
  5. 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

1. Binary Addition Rules:
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.

Frequently Asked Questions

How do you convert binary to decimal? +
Multiply each binary digit by its corresponding power of two (starting at 2⁰ on the right) and sum the products. For example, 1011₂ equals (1×8) + (0×4) + (1×2) + (1×1) = 11.
What is the difference between binary AND and XOR? +
The AND operation returns 1 only when both compared bits are 1. The XOR (exclusive OR) operation returns 1 when the compared bits differ (one is 1 and the other is 0), returning 0 if both bits match.
Why does binary addition produce carry bits? +
Because binary contains only digits 0 and 1, adding 1 + 1 equals two, which cannot be represented as a single digit. It produces a sum of 0 and propagates a carry of 1 into the next column.
How does bit shifting work? +
Shifting bits to the left (<<) moves all bits toward higher significance and appends zeros on the right, multiplying the number by 2 per shift. Shifting right (>>) drops low bits, dividing by 2.
Methodology, Sources & Technical Standards: Computations adhere to IEEE positional number standards, ISO/IEC 10646 character encoding, and standard Boolean algebra. Arithmetic operations utilize arbitrary-precision BigInt logic to prevent 32-bit integer overflow truncations.
✓ Copied to Clipboard!