All calculators

General calculator

Binary Calculator

Calculate binary arithmetic (add, subtract, multiply, divide) and logical bitwise operations (AND, OR, XOR). Convert base-2 to decimal, hex, and octal.

Introduction

The Binary Calculator is a technical tool designed to perform math and bitwise logical operations on base-2 (binary) numbers. Used extensively in computer science, software engineering, and digital electronics, this tool supports standard arithmetic operations (+, -, *, /) as well as bitwise logic gates (AND, OR, XOR). It processes binary strings instantly and outputs equivalent values in binary, decimal (base-10), hexadecimal (base-16), and octal (base-8).

How to Use

Input two binary values containing only the digits 0 and 1. Select your desired operation from the dropdown (Arithmetic: Add, Subtract, Multiply, Divide; or Logical: AND, OR, XOR). Click the Calculate button to view the results in binary, decimal, hexadecimal, and octal formats.

Formula

Binary Math: Operands are converted to decimal, the selected operation is executed, and the resulting decimal is converted back to binary, hexadecimal, and octal representations.

Examples

Example 1 (Addition): 1010 (10) + 101 (5) = 1111 (15). Example 2 (Bitwise AND): 1100 (12) AND 1010 (10) = 1000 (8). Example 3 (Bitwise XOR): 1100 (12) XOR 1010 (10) = 0110 (6).

Results Explained

The results display the computed answer across multiple numeral systems: Binary (base-2), Decimal (base-10), Hexadecimal (base-16), and Octal (base-8), making it easy to cross-verify low-level code.

What Is the Binary Number System (Base-2)?

The binary number system, or base-2 numeral system, is the foundational language of modern computer systems. Unlike the decimal system (base-10) we use in everyday life—which utilizes ten distinct digits (0 through 9)—the binary system uses only two digits: 0 and 1. Each digit in a binary sequence is called a bit (short for binary digit).

Computers use binary because it maps perfectly to the physical state of digital electronics. Computer processors are composed of billions of microscopic transistors that act as electronic switches. A transistor can be in one of two states: "off" (representing 0, or low voltage) or "on" (representing 1, or high voltage). By combining these simple off/on states into sequences, computers can represent complex numbers, characters, images, software programs, and media.

A Brief History of Binary Math

Although modern binary computers were developed in the mid-20th century, the concept of base-2 mathematics dates back thousands of years. Ancient cultures in Egypt, China, and India utilized binary-like systems. For instance, the ancient Chinese text I Ching features 64 hexagrams that represent dualistic cosmological forces, mapping directly to 6-bit binary sequences.

In 1703, the German mathematician and philosopher Gottfried Wilhelm Leibniz published his seminal paper, "Explanation of Binary Arithmetic," which formalized the system we use today. Leibniz believed that binary represented a pure form of mathematical logic. Later, in 1854, English mathematician George Boole introduced "Boolean Algebra"—a system of logic gates (AND, OR, NOT) that laid the mathematical foundation for digital circuit design and programming languages.

Manual Binary Arithmetic Rules

Just like decimal numbers, binary numbers can be added, subtracted, multiplied, and divided manually. The rules are simpler because there are only two digits to manage:

1. Binary Addition

Adding binary columns follows four basic rules:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 0 (carry 1 to the next column)
  • 1 + 1 + 1 = 1 (carry 1 to the next column)

2. Binary Subtraction

Subtraction requires borrowing from the next significant column when subtracting 1 from 0:

  • 0 - 0 = 0
  • 1 - 0 = 1
  • 1 - 1 = 0
  • 0 - 1 = 1 (requires borrowing 1 from the next column, turning the 0 into a 10 in base-2, which is 2 in decimal. 2 - 1 = 1)

Bitwise Logical Operations (Truth Tables)

In addition to arithmetic, binary numbers can undergo bitwise logical operations. These treat bits in corresponding positions as logical inputs. Here are the three most common bitwise operations:

Bitwise AND (&)

The result is 1 ONLY if both input bits are 1. Otherwise, the result is 0:

A B A AND B
000
010
100
111

Bitwise OR (|)

The result is 1 if at least one of the input bits is 1:

A B A OR B
000
011
101
111

Bitwise XOR (^) - Exclusive OR

The result is 1 if the input bits are different. If they are the same, the result is 0:

A B A XOR B
000
011
101
110

Three Detailed Worked Examples

Example 1: Adding 1010 (10) and 1101 (13)

Let's add these binary values column by column (from right to left):

  • Col 1 (rightmost): 0 + 1 = 1
  • Col 2: 1 + 0 = 1
  • Col 3: 0 + 1 = 1
  • Col 4: 1 + 1 = 10 (Write 0, carry 1 to Col 5)
  • Col 5: Carry 1 + 0 + 0 = 1
  • Result: 10111 (which converts to 23 in decimal).

Example 2: Bitwise XOR on 1100 and 1010

We compare each bit index from left to right:

  • Index 1: 1 XOR 1 = 0 (same)
  • Index 2: 1 XOR 0 = 1 (different)
  • Index 3: 0 XOR 1 = 1 (different)
  • Index 4: 0 XOR 0 = 0 (same)
  • Result: 0110 (or 6 in decimal).

Example 3: Division (1110 / 11)

We want to divide 1110 (14) by 11 (3).

  • How many times does 11 go into 11? 1 time. Write 1. Remainder is 0.
  • Bring down the next bit (1). Can 11 go into 01? 0 times. Write 0.
  • Bring down the final bit (0). Can 11 go into 10 (2)? 0 times. Write 0.
  • Result: Quotient is 100 (4), with a remainder of 10 (2).
  • Our calculator performs standard integer division, outputting the quotient: 100 (which is 4 in decimal).

Frequently Asked Questions

What is a Binary Calculator?

It is a specialized calculator that performs mathematical operations (addition, subtraction, multiplication, division) and logical bitwise operations (AND, OR, XOR) on binary numbers.

Why do computers use binary?

Computers use binary because digital electronics rely on transistors that can easily represent two physical states: "on" (1, high voltage) or "off" (0, low voltage).

What is a bit and a byte?

A bit is the smallest unit of digital data, representing a single 0 or 1. A byte is a group of 8 bits, which can represent 256 unique values (0 to 255).

How do you convert binary to decimal?

Assign powers of 2 to each bit position from right to left (1, 2, 4, 8, 16, etc.) and add the values of the positions that contain a 1. For example, 1010 is 8 + 0 + 2 + 0 = 10.

How do you convert decimal to binary?

Divide the decimal number by 2 repeatedly and record the remainders (0 or 1) in reverse order. For example, 13 / 2 = 6 r 1, 6 / 2 = 3 r 0, 3 / 2 = 1 r 1, 1 / 2 = 0 r 1. Reading the remainders backward gives 1101.

What does the AND operator do in binary?

Bitwise AND compares two binary strings bit by bit. The output bit is 1 only if both input bits are 1. For example, 1100 AND 1010 is 1000.

What does the OR operator do in binary?

Bitwise OR compares two binary strings. The output bit is 1 if either of the input bits is 1. For example, 1100 OR 1010 is 1110.

What does the XOR operator do?

Bitwise XOR (Exclusive OR) outputs a 1 if the input bits are different, and a 0 if they are identical. For example, 1100 XOR 1010 is 0110.

How does the calculator handle negative numbers?

The calculator represents negative results with a minus sign (e.g., -101) for ease of reading, alongside the corresponding negative decimal equivalent.

What is hexadecimal?

Hexadecimal (base-16) is a numeral system that uses 16 symbols: 0-9 and A-F. It is commonly used as a human-friendly shorthand to represent long binary strings.

What is octal?

Octal (base-8) is a numeral system that uses 8 digits (0-7). It was widely used in older computing systems because groups of 3 bits map directly to octal digits.

Can I perform operations on fractional binary numbers?

This calculator is designed for integers. It performs standard integer arithmetic, dropping any fractional parts during division.

What happens if I divide a binary number by zero?

Just like in decimal math, dividing by zero is undefined. The calculator will indicate an error or return null.

What is Leibniz's contribution to binary?

Gottfried Wilhelm Leibniz formalized the modern binary system in 1703, showing that it could be used to perform arithmetic and logical reasoning.

What is the binary equivalent of 100?

The decimal number 100 is represented in binary as 1100100.