Computer Arithmetic – Notes on Computer Architecture


Computer arithmetic is a vital part of computer architecture, focusing on how a computer performs mathematical operations like addition, subtraction, multiplication, and division using binary numbers. Every digital system—from a calculator to a supercomputer—relies on these arithmetic operations.

Computer Arithmetic – Notes on Computer Architecture



1. Data Representation

Computers represent all data in binary form (0s and 1s) because digital circuits operate using two voltage levels (ON and OFF).

  • Binary Number System: Uses only two digits, 0 and 1.
    Example: Decimal 5 = Binary 101.

  • Octal (base 8) and Hexadecimal (base 16) are also used to simplify binary notation.

  • 1 byte = 8 bits (smallest storage unit).

Layman Example:
Think of “1” as the light switch ON and “0” as OFF. Complex numbers are built by combining these ON/OFF states.


2. Provision for Decimal Position

In binary arithmetic, numbers can be integer or fractional.

  • Binary Point: Similar to the decimal point in base-10.
    Example: Binary 101.1 = Decimal 5.5.

  • Position after the binary point determines the fraction (each bit represents 1/2, 1/4, 1/8, etc.).


3. Provision for Sign Representation

Computers need a method to represent positive and negative numbers.

  • Sign-Magnitude: Leftmost bit is the sign bit. (0 for +, 1 for -)
    Example: +5 = 0101, -5 = 1101

  • 1’s Complement: Flip all bits to represent a negative number.

  • 2’s Complement (Most common): Flip bits and add 1.
    Example: +5 = 0101 → -5 = 1011

Why 2’s Complement?
It simplifies subtraction and hardware design—only one adder circuit is needed.


4. Integer Arithmetic

Refers to mathematical operations performed on whole numbers.

  • Addition/Subtraction: Done using binary addition rules with carry/borrow bits.

  • Overflow: Occurs when the result exceeds the number of bits available.
    Example: 8-bit register, 127 + 1 = overflow.


5. Unsigned Binary Multiplication Algorithm

Used when both numbers are positive (no sign bit involved).

Steps:

  1. Multiply the multiplier bit by the multiplicand.

  2. Shift the partial product left by one position after each step.

  3. Add all partial products.

Example:
110 × 101 (6 × 5 = 30 in decimal)
The algorithm gives 11110 (which equals 30).


6. Signed Binary Multiplication (Booth’s Algorithm)

Booth’s algorithm handles negative numbers efficiently in binary multiplication.

Key Points:

  • Reduces the number of addition/subtraction operations.

  • Works by encoding the multiplier bits using rules based on bit transitions.

Simplified Example:
For 3 × 4, Booth’s algorithm manipulates binary forms of both numbers and gives the correct signed result using fewer steps.


7. Unsigned Binary Division Algorithm

Division in binary follows repeated subtraction and shifting.

Steps:

  1. Align the divisor with the dividend.

  2. Subtract the divisor where possible and write the quotient bits.

  3. Shift the divisor right for the next bit test.

Example:
1100 ÷ 10 → 6 in decimal ÷ 2 = quotient 110.


8. Representation of Fractions

Fractions in binary can be represented as:

  • Fixed Point: The Binary point is fixed after a certain bits.

  • Floating Point: Binary point “floats” depending on the exponent value.

Example:
Fixed: 1010.01 = 10.25
Floating: 1.01001×231.01001 \times 2^3


9. Fixed Point Representation

Used when the range and precision of numbers are limited.

  • The binary point is fixed at one position.

  • Simpler, faster, and used in embedded systems.

Example:
Digital clocks and microcontrollers commonly use fixed-point math.


10. Floating Point Representation

Used for large or very small numbers—similar to scientific notation.

IEEE-754 Format:

  • Sign bit (1 bit)

  • Exponent (8 bits)

  • Mantissa (23 bits)

Example:
Decimal 10.75 = 1.01011×231.01011 × 2^3

Allows representation of both huge and tiny values with precision.


11. Floating-Point Arithmetic

Operations include addition, subtraction, multiplication, and division using normalised floating-point formats.

Challenges:

  • Rounding errors may occur.

  • Normalisation ensures the mantissa fits within the format.

Example: Used in graphics rendering, physics engines, and financial calculations.


12. BCD (Binary Coded Decimal) Arithmetic Unit

BCD represents each decimal digit separately in 4 bits.

Example:
Decimal 59 = BCD 0101 1001.

Used in calculators where exact decimal representation is critical.


13. BCD Adder

A specialised circuit that adds two BCD digits.

Key Steps:

  1. Add the binary digits.

  2. If the sum exceeds 9, add 6 (0110) to correct it.

Example:
Add 7 (0111) and 8 (1000) → 1111 (15), corrected to 0001 0101 (15 decimal).


14. Pipelining

Pipelining speeds up arithmetic operations by dividing them into stages—like an assembly line.

  • Each stage performs a specific task.

  • Multiple operations can overlap in execution.

Example: CPU adds one number while fetching the next instruction.


15. Arithmetic Pipelining

Special type of pipelining applied to arithmetic operations (like floating-point addition/multiplication).

Benefits:

  • Increases instruction throughput.

  • Reduces overall computation time.

Used in modern processors and GPUs for high-speed arithmetic calculations.


Key Takeaways

  • All computer arithmetic starts from binary representation.

  • 2’s complement simplifies the handling of negative numbers.

  • Booth’s algorithm and pipelining improve performance.

  • Floating-point and BCD arithmetic handle precision-critical tasks.

  • Understanding these basics helps in system design, compiler optimisation, and numerical software development.