Ugenz Academy/IoT Tutorial

Binary Arithmetic

6 min read1,198 words

Reading progress

Keep learning

Binary Arithmetic in Digital Electronics

1. Introduction

Binary arithmetic is the process of performing mathematical operations using the binary number system, which contains only two digits: 0 and 1.

Computers, microcontrollers, processors, and digital circuits use binary arithmetic to perform calculations and process data.

The main operations are:

  • Binary addition
  • Binary subtraction
  • Binary multiplication
  • Binary division

Binary arithmetic is important in digital electronics because arithmetic logic units (ALUs) inside processors perform calculations using binary data.

2. Basic Rules of Binary Arithmetic

Before performing calculations, remember that binary uses only two digits.

Binary addition rules

OperationResult
0+00+00
0+10+11
1+01+01
1+11+110

The most important rule is:

1+1=102\boxed{1+1=10_2}

This means write 0 and carry 1 to the next column. The result is decimal 2, represented as 10 in binary.

Binary subtraction rules

OperationResult
0−00-00
1−01-01
1−11-10
0−10-1Borrow from the next column

When subtracting 00 from 11 in the reverse order, 0−10-1, borrow a 1 from the next column. The borrowed binary 1 has a value of 2 in the current column, so 102−12=1210_2-1_2=1_2.

3. Binary Addition

Binary addition works like decimal addition, but each column can contain only 0 or 1. When a column's total is 2 or 3, a carry is passed to the next column.

Example 1: Add 1012+0112101_2+011_2

   101
 + 011
 -----
  1000

Step-by-step:

  1. Rightmost column: 1+1=1021+1=10_2. Write 0, carry 1.
  2. Middle column: 0+1+1=1020+1+1=10_2. Write 0, carry 1.
  3. Leftmost column: 1+0+1=1021+0+1=10_2. Write 0, carry 1.
  4. Write the remaining carry at the front.

Therefore,

1012+0112=10002\boxed{101_2+011_2=1000_2}

Verification in decimal: 5+3=85+3=8.

Example 2: Add 11012+101121101_2+1011_2

    1101
  + 1011
  ------
   11000

Converting to decimal to verify:

11012=13_101101_2=13\_{10} 10112=11_101011_2=11\_{10} 13+11=2413+11=24

Therefore,

11012+10112=110002\boxed{1101_2+1011_2=11000_2}

4. Binary Subtraction

Binary subtraction follows the same column-by-column process as decimal subtraction, but borrowing is based on powers of 2.

Example 1: Subtract 1012−0112101_2-011_2

    101
  - 011
  -----
     10

The calculation can be verified in decimal:

1012=5_10,0112=3_10101_2=5\_{10},\qquad 011_2=3\_{10} 5−3=25-3=2

Thus,

1012−0112=0102\boxed{101_2-011_2=010_2}

The leading zero can be omitted, giving 10210_2.

Example 2: Subtract 11002−010121100_2-0101_2

    1100
  - 0101
  ------
    0111

In decimal:

11002=12_101100_2=12\_{10} 01012=5_100101_2=5\_{10} 12−5=712-5=7

Therefore,

11002−01012=01112\boxed{1100_2-0101_2=0111_2}

Understanding binary borrowing

Consider 102−1210_2-1_2:

102=2_10,12=1_1010_2=2\_{10},\qquad 1_2=1\_{10} 2−1=12-1=1

So,

102−12=12\boxed{10_2-1_2=1_2}

A 1 borrowed from the next binary place represents a value of 2 in the current place.

5. Binary Multiplication

Binary multiplication is simpler than decimal multiplication because the only possible single-digit products are:

MultiplicationResult
0×00\times00
0×10\times10
1×01\times00
1×11\times11

Example 1: Multiply 1012×112101_2\times11_2

      101
    ×  11
    -----
      101
     1010
    -----
     1111

Explanation:

  • Multiply 101 by the rightmost 1: the result is 101.
  • Multiply 101 by the next 1: shift the result one place left to get 1010.
  • Add the two partial results.
1012×112=11112\boxed{101_2\times11_2=1111_2}

Verification in decimal:

5×3=155\times3=15

And 11112=15_101111_2=15\_{10}.

Example 2: Multiply 1102×1012110_2\times101_2

       110
     × 101
     -----
       110
      0000
     11000
     -----
     11110

Therefore,

1102×1012=111102\boxed{110_2\times101_2=11110_2}

Verification: 6×5=306\times5=30, and 111102=30_1011110_2=30\_{10}.

6. Binary Division

Binary division follows the same general method as decimal long division: divide, multiply, subtract, and bring down the next digit.

Example 1: Divide 110021100_2 by 10210_2

11002=12_101100_2=12\_{10} 102=2_1010_2=2\_{10}

Therefore,

12÷2=612\div2=6

Since 6_10=11026\_{10}=110_2,

11002÷102=1102\boxed{1100_2\div10_2=110_2}

Example 2: Divide 111121111_2 by 11211_2

11112=15_101111_2=15\_{10} 112=3_1011_2=3\_{10} 15÷3=515\div3=5

Since 5_10=10125\_{10}=101_2,

11112÷112=1012\boxed{1111_2\div11_2=101_2}

Binary division can produce a remainder, just like decimal division. Division by zero is undefined in binary as well.

7. One's Complement and Two's Complement

Digital systems need ways to represent negative numbers and perform subtraction using binary addition.

A. One's complement

The one's complement of a binary number is obtained by reversing every bit:

  • Change each 0 to 1.
  • Change each 1 to 0.

Example:

Original:          10110010
One's complement:  01001101

Thus, the one's complement of 10110010210110010_2 is 01001101201001101_2.

B. Two's complement

The two's complement is obtained by taking the one's complement and adding 1.

Example:

Original:          00000101
One's complement:  11111010
Add 1:             00000001
                   --------
Two's complement:  11111011

Therefore, the 8-bit two's complement of 00000101200000101_2 is

111110112\boxed{11111011_2}

In the standard 8-bit signed two's-complement representation, this bit pattern represents −5-5.

Two's complement is widely used in processors because it allows signed addition and subtraction to be performed using the same binary adder hardware.

8. Binary Arithmetic in Digital Circuits

Binary arithmetic is performed by digital circuits called arithmetic circuits, which are commonly part of a processor's Arithmetic Logic Unit (ALU).

Unsigned vs. Signed Binary Numbers, Part 2

PPT - Design of 4-bit ALU PowerPoint Presentation, free download - ID:335270

How Do Calculators Work? » ScienceABC

8

A. Half Adder

A half adder adds two single-bit binary inputs, AA and BB, and produces two outputs: Sum and Carry.

S=A⊕B\boxed{S=A\oplus B} C=A⋅B\boxed{C=A\cdot B}

Here, ⊕\oplus represents XOR and ⋅\cdot represents AND.

ABSumCarry
0000
0110
1010
1101

For example, 1+1=1021+1=10_2, so the Sum is 0 and the Carry is 1.

B. Full Adder

A full adder adds three single-bit inputs: AA, BB, and an incoming carry C_inC\_{\text{in}}.

Its outputs are Sum and Carry-out.

S=A⊕B⊕C_inS=A\oplus B\oplus C\_{\text{in}} C_out=AB+C_in(A⊕B)C\_{\text{out}}=AB+C\_{\text{in}}(A\oplus B)

Full adders can be connected together to add multi-bit binary numbers.

C. Arithmetic Logic Unit (ALU)

An ALU is a processor component that performs arithmetic and logical operations, including:

  • Binary addition and subtraction
  • Comparisons
  • AND, OR, and XOR operations
  • Bit shifting

These operations support calculations, data processing, and program execution.

9. Binary Arithmetic Summary

OperationExampleResult
Addition1012+0112101_2+011_2100021000_2
Subtraction1012−0112101_2-011_20102010_2
Multiplication1012×112101_2\times11_2111121111_2
Division11002÷1021100_2\div10_21102110_2
One's complementInvert 10100101
Two's complementInvert 0101, add 11011 (4-bit result)

Important: In fixed-width binary arithmetic, a result may exceed the number of available bits. This can cause overflow, meaning the result cannot be represented correctly within that fixed width. Signed and unsigned overflow are handled differently.

Binary arithmetic is fundamental to digital electronics, logic gates, processors, microcontrollers, and computer architecture.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy