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
| Operation | Result |
|---|---|
| 0 | |
| 1 | |
| 1 | |
| 10 |
The most important rule is:
This means write 0 and carry 1 to the next column. The result is decimal 2, represented as 10 in binary.
Binary subtraction rules
| Operation | Result |
|---|---|
| 0 | |
| 1 | |
| 0 | |
| Borrow from the next column |
When subtracting from in the reverse order, , borrow a 1 from the next column. The borrowed binary 1 has a value of 2 in the current column, so .
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
101
+ 011
-----
1000
Step-by-step:
- Rightmost column: . Write
0, carry1. - Middle column: . Write
0, carry1. - Leftmost column: . Write
0, carry1. - Write the remaining carry at the front.
Therefore,
Verification in decimal: .
Example 2: Add
1101
+ 1011
------
11000
Converting to decimal to verify:
Therefore,
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
101
- 011
-----
10
The calculation can be verified in decimal:
Thus,
The leading zero can be omitted, giving .
Example 2: Subtract
1100
- 0101
------
0111
In decimal:
Therefore,
Understanding binary borrowing
Consider :
So,
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:
| Multiplication | Result |
|---|---|
| 0 | |
| 0 | |
| 0 | |
| 1 |
Example 1: Multiply
101
× 11
-----
101
1010
-----
1111
Explanation:
- Multiply
101by the rightmost1: the result is101. - Multiply
101by the next1: shift the result one place left to get1010. - Add the two partial results.
Verification in decimal:
And .
Example 2: Multiply
110
× 101
-----
110
0000
11000
-----
11110
Therefore,
Verification: , and .
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 by
Therefore,
Since ,
Example 2: Divide by
Since ,
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
0to1. - Change each
1to0.
Example:
Original: 10110010
One's complement: 01001101
Thus, the one's complement of is .
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 is
In the standard 8-bit signed two's-complement representation, this bit pattern represents .
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, and , and produces two outputs: Sum and Carry.
Here, represents XOR and represents AND.
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
For example, , so the Sum is 0 and the Carry is 1.
B. Full Adder
A full adder adds three single-bit inputs: , , and an incoming carry .
Its outputs are Sum and Carry-out.
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
| Operation | Example | Result |
|---|---|---|
| Addition | ||
| Subtraction | ||
| Multiplication | ||
| Division | ||
| One's complement | Invert 1010 | 0101 |
| Two's complement | Invert 0101, add 1 | 1011 (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.