Binary Calculator

Do arithmetic and bitwise operations on binary numbers.

Binary Calculator tool

—
Result in binary
—
Decimal
—
Hexadecimal
—
Check in decimal

About the Binary Calculator

Computer science students and programmers work with binary numbers when learning how processors add, compare and store values. This binary calculator performs exact arithmetic on binary numbers of any length, so 1011 + 0110 = 10001, which is 11 + 6 = 17 in decimal, along with bitwise AND, OR, XOR and left and right shifts, and it shows decimal and hexadecimal equivalents for every result.

Binary arithmetic follows the same rules as decimal, but carries happen at 2 instead of 10: 1 + 1 = 10, which is 0 carry 1. Multiplication is shifting and adding, and division is repeated subtraction. Bitwise operations compare the numbers bit by bit: AND gives 1 only where both bits are 1, OR where either is 1, and XOR where exactly one is 1. A left shift by n multiplies by 2ⁿ and a right shift divides by 2ⁿ, dropping any remainder.

Example: 1011 + 110 = 10001, which in decimal is 11 + 6 = 17. 1011 − 110 = 101 (5), 1011 × 110 = 1000010 (66), and 1011 ÷ 110 = 1 remainder 101 (11 ÷ 6 = 1 remainder 5). Bitwise, 1011 AND 110 = 10 (2), 1011 OR 110 = 1111 (15) and 1011 XOR 110 = 1101 (13).

To convert numbers between bases, use the decimal to binary converter or the binary to hex converter; for hexadecimal arithmetic, the hex calculator; and to turn text into bits, the text to binary converter.

How to use the Binary Calculator

  1. Enter the first binary numberType 0s and 1s; spaces between groups are ignored.
  2. Choose an operationAdd, subtract, multiply, divide, AND, OR, XOR or shift.
  3. Enter the second numberAnother binary number, or the number of places for a shift.
  4. Read the resultSee the binary answer with its decimal and hex values and a decimal check.

Binary Calculator features

  • Addition, subtraction, multiplication and division
  • AND, OR, XOR, left and right shift
  • Exact for binary numbers of any length
  • Quotient and remainder for division
  • Decimal and hexadecimal equivalents
  • Decimal check of every operation
  • Negative results shown with a minus sign

Common uses

  • Computer science and digital electronics homework
  • Checking bit masks and flags in code
  • Understanding two's complement and shifts
  • Networking and subnet bit math
  • Exam practice on binary arithmetic

Binary arithmetic in practice: subnets, permissions, bitmasks and overflow

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Binary is the number system computers use, with only the digits 0 and 1. Binary arithmetic and bitwise operations are not just classroom exercises: they configure networks, set file permissions, store options compactly and explain strange bugs when numbers overflow. This guide covers those practical uses, including a worked subnet calculation, how two's complement stores negative numbers and why an 8-bit value wraps from 255 to 0.

Bits and bytes

Each binary digit is a bit, and 8 bits make a byte, which can represent 256 different values, from 0 to 255. Larger groups hold more: 16 bits give 65,536 values and 32 bits about 4.3 billion. Knowing these limits explains many everyday technical details, from the maximum value in a colour channel to the number of addresses in older internet protocols.

Network subnets

Internet addresses in IPv4 are 32-bit numbers written as four bytes, such as 192.168.1.77. A subnet mask, such as 255.255.255.192, marks which bits identify the network. Combining the address and the mask with a bitwise AND gives the network address.

A worked example: finding a network address

For 192.168.1.77 with the mask 255.255.255.192, the first three bytes pass through unchanged because 255 is all ones. For the last byte, 77 is 01001101 in binary and 192 is 11000000. ANDing them keeps only the bits where both are 1, giving 01000000, which is 64. The network address is therefore 192.168.1.64, and this subnet covers addresses 64 to 127.

Network engineers do this calculation constantly, often with tools, to check which devices can communicate directly and how many addresses a subnet holds.

File permissions

On Linux and other Unix-like systems, file permissions are three groups of three bits: read, write and execute for the owner, the group and everyone else. Each group is often written as an octal digit. The common setting 755 means 111 101 101 in binary: the owner can read, write and execute, while others can read and execute. Understanding the bits makes permission codes much less mysterious.

Bitmasks and flags

Programs often store several on-or-off options in one number, one bit per option. To turn an option on, OR the number with that bit; to test it, AND with the bit; to turn it off, AND with the inverted bit; and XOR toggles it. This saves space and lets many options be checked at once, which is why bitmasks appear in operating systems, games and network protocols.

Two's complement for negative numbers

Computers usually store signed integers in two's complement. In 8 bits, positive numbers run from 0 to 127, and negative numbers from −1 to −128 use patterns starting with 1. To negate a number, invert all its bits and add 1: 5 is 00000101, so −5 is 11111011. The method lets the same addition circuit handle positive and negative numbers.

Overflow

When a calculation exceeds the range of its bits, it overflows and wraps around. An unsigned 8-bit value of 255 plus 1 becomes 0, and a signed 8-bit value of 127 plus 1 becomes −128. Overflow has caused real software bugs, which is why programmers choose number types with enough bits for the values they expect and check for overflow in critical code.

Shifts as multiplication

Shifting a binary number one place to the left doubles it, and shifting right halves it, discarding any remainder. Programmers sometimes use shifts for fast multiplication or division by powers of two, and they are essential for packing and unpacking data in network messages and file formats.

Common mistakes

  • Forgetting leading zeros when lining up bits.
  • Confusing bitwise AND and OR with logical operators in code.
  • Ignoring the bit width when working with negative numbers.
  • Overlooking overflow in fixed-size variables.

Related tools

For base conversions, use Number Base Converter. For hexadecimal arithmetic, try Hex Calculator, and for decimal to binary, Decimal to Binary Converter.

Colours in binary

Digital colours are usually stored with 8 bits for each of red, green and blue, so each channel has 256 levels and a colour uses 24 bits. That gives 2²⁴, or 16,777,216, possible colours. The hexadecimal colour codes used on websites, such as #FF8800, are simply these three bytes written in base 16, which is a compact way to write binary.

Counting on your fingers in binary

If each finger represents a bit, raised for 1 and lowered for 0, two hands can count from 0 to 1,023, because ten bits have 2¹⁰ combinations. It is a fun way to see place value in binary: the thumb on one hand is 1, the next finger 2, then 4, 8, 16 and so on, doubling each time, which is exactly how binary digits work.

Reading binary quickly

To convert binary to decimal in your head, write the place values above the bits, 128, 64, 32, 16, 8, 4, 2 and 1 for a byte, and add the values where the bit is 1. For 01001101, that is 64 + 8 + 4 + 1 = 77. With a little practice, common bytes become recognisable at a glance, which helps when reading network configurations and low-level data.

Limits

Arithmetic is exact for whole numbers; signed results are shown for the bit width selected.

Frequently asked questions

How do I add binary numbers?

Add column by column from the right, like decimal addition: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1). So 1011 + 110 = 10001.

How do I subtract binary numbers?

Subtract column by column, borrowing 2 instead of 10 when the top bit is smaller: 10 − 1 = 1. Computers usually subtract by adding the two's complement of the second number instead.

How do I multiply binary numbers?

Multiply by each bit of the second number, which is either a copy of the first number shifted left or zero, then add the partial products. 1011 × 110 = 10110 + 101100 = 1000010.

What do AND, OR and XOR do?

They compare bits in the same position. AND gives 1 when both bits are 1, OR when at least one is 1, and XOR when exactly one is 1. They are used for masks, flags and simple checksums.

What does a bit shift do?

A left shift moves every bit left and adds zeros on the right, multiplying by 2 for each place. A right shift moves bits right and drops the last ones, dividing by 2 and discarding the remainder.

How are negative binary numbers stored?

Most computers use two's complement: invert every bit and add 1. In 8 bits, −5 is 11111011. This calculator shows negative results with a minus sign instead, so they are easy to read at any length.

Why do computers use binary?

Because electronic circuits are reliable when they only need to tell two states apart, such as low and high voltage. Every number, character and image is ultimately stored as patterns of 0s and 1s.

How do I convert binary to decimal?

Multiply each bit by its place value, a power of 2 starting from 1 on the right, and add the results. 1011 = 8 + 0 + 2 + 1 = 11. The calculator shows every result in decimal automatically.