100+ free calculators - no signup, no ads | 💰 Financial ❤️ Health & Fitness 📐 Math 🔧 Other
🇺🇸 USD | About Contact

Binary Arithmetic Calculator

Add, subtract, multiply, or divide two binary numbers. Column workings and decimal equivalents shown.

Result

Number Base Converter

Convert any number between binary, decimal, hexadecimal, and octal. Enter in any field to convert to all others.

Conversion Details

Bitwise Operations

AND, OR, XOR, NOT on two binary values. Bit-by-bit truth table shown.

Result

Binary to Decimal

Enter a binary number to see its decimal value with full positional breakdown.

Decimal Value

Decimal to Binary

Enter a decimal integer to see its binary representation using repeated division by 2.

Binary Value

The Binary Number System

The binary system uses base 2 with only the digits 0 and 1. Each digit is called a bit. Each position in a binary number represents a power of 2, starting at 2⁰ (= 1) on the right and increasing to the left.

Binary 10110 = 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰ = 16 + 0 + 4 + 2 + 0 = 22

Converting Decimal to Binary

Divide the decimal number by 2 repeatedly. Record the remainder (0 or 1) at each step. Read the remainders from the last division to the first - that is the binary representation.

Convert 25 to binary: 25 ÷ 2 = 12 remainder 1 12 ÷ 2 = 6 remainder 0 6 ÷ 2 = 3 remainder 0 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 Read bottom to top: 11001 Check: 16+8+0+0+1 = 25 ✓

Binary Place Values

Bit PositionPowerValueBinary Example
0 (rightmost)2⁰100000001
12¹200000010
22²400000100
32³800001000
42⁴1600010000
7 (MSB of byte)2⁷12810000000

Binary Arithmetic Rules

Addition

Column-by-column from right to left. Four basic cases:

0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 (write 0, carry 1) 1 + 1 + 1(carry) = 11 (write 1, carry 1)

Subtraction

Same column process, but borrow from the left when subtracting 1 from 0. Borrowing converts a 0 to 10 (two) in the current column, allowing the subtraction to proceed. Each borrow reduces the column to the left by 1.

0 - 0 = 0 1 - 0 = 1 1 - 1 = 0 0 - 1 = borrow: 10 - 1 = 1 (borrow 1 from left)

Multiplication

Long multiplication with shifts. Each bit of the multiplier either produces 0 (multiply by 0) or copies the multiplicand (multiply by 1), shifted left by that bit's position. Sum all partial products.

Division

Long division as in decimal. At each step, determine whether the divisor fits into the current partial dividend: if yes write 1 and subtract; if no write 0 and bring down the next bit. The remainder is what's left after all bits are processed.

ℹ️
A fast way to multiply or divide by a power of 2: shift the bits left (multiply by 2) or right (divide by 2). Shifting 1011 (=11) left by one position gives 10110 (=22). Shifting 1100 (=12) right by one position gives 110 (=6). This is why bit shifts are used in low-level programming for fast multiplication and division.

Bitwise Operations

Bitwise operations apply a logical function to every corresponding pair of bits in two numbers. They work at the individual bit level and form the foundation of low-level programming, hardware design, and cryptography.

ABANDORXORNANDNORXNOR
00000111
01011100
10011100
11110001

Practical Uses of Bitwise Operations

  • AND (masking): Isolate specific bits. value AND 0x0F extracts the lower 4 bits (nibble) of any byte. Used in IP address subnet masking.
  • OR (setting bits): Turn specific bits on. value OR 0x80 sets the most significant bit. Used to enable flags in a bitmask register.
  • XOR (toggling / encryption): Flip specific bits. A XOR A = 0 (any value XORed with itself is zero). XOR with a key produces a simple cipher. XOR is also used in parity checking and error detection.
  • NOT (complement): Flips every bit. In two's complement systems, the negative of a number is NOT(n) + 1. For a signed 8-bit number, NOT(00000001) = 11111110, and 11111110 + 1 = 11111111 = -1.
  • Left shift (<<): Multiplies by 2 per shift. n << 1 = 2n. Used in fast multiplication and constructing bitmasks.
  • Right shift (>>): Divides by 2 per shift (floor division). Used in fast division and extracting high-order bits.

Hexadecimal and Octal

Hexadecimal (Base 16)

Hexadecimal uses digits 0 to 9 and letters A to F, where A=10, B=11, C=12, D=13, E=14, F=15. Each hex digit represents exactly 4 bits (one nibble), making conversion between binary and hex straightforward: group bits into fours from the right and convert each group.

Binary 10110101 to hex: 1011 = B · 0101 = 5 Result: B5 (= 181 decimal)

Hex is used everywhere in computing: memory addresses, colour codes (#FF5733), assembly language, byte dumps, and network protocol analysis. Two hex digits always represent one byte (8 bits), so a 32-bit integer maps to 8 hex digits.

Octal (Base 8)

Octal uses digits 0 to 7. Each octal digit represents exactly 3 bits. Unix/Linux file permissions use octal: 755 = 111 101 101 in binary, meaning owner has read-write-execute (7), group has read-execute (5), others have read-execute (5).

Binary 10110101 to octal: 010 = 2 · 110 = 6 · 101 = 5 Result: 265 octal (= 181 decimal)

Frequently Asked Questions

How do you add two binary numbers?
Add column by column from right to left using four rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (write 0 carry 1). If there's also a carried 1: 1+1+1=11 (write 1 carry 1). The carry propagates left just like in decimal addition. Example: 1011 + 0110 = 10001 (11 + 6 = 17 in decimal, verified).
What does each hex digit represent in binary?
Each hexadecimal digit maps to exactly 4 binary bits (a nibble). 0=0000, 1=0001, 2=0010, 3=0011, 4=0100, 5=0101, 6=0110, 7=0111, 8=1000, 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. To convert from binary to hex, group bits in sets of 4 starting from the right and replace each group with the corresponding hex digit.
How does binary subtraction with borrowing work?
When you subtract 1 from 0 in a column, you borrow from the next column to the left. The 0 becomes 10 (binary two) in the current column, making the subtraction 10-1=1. The column you borrowed from has its value reduced by 1. If that column was also 0, you need to borrow further left, cascading the borrow. Example: 1000 - 0011 = 0101 (8-3=5). The leftmost 1 provides a chain of borrows.
What is two's complement?
Two's complement is the standard way computers represent negative integers in binary. To negate a number: flip all bits (one's complement) then add 1. For 8-bit: 5 = 00000101; flip all bits: 11111010; add 1: 11111011 = -5 in two's complement. The advantage is that addition works correctly for both positive and negative numbers with no special cases, which is why all modern CPUs use two's complement.