Module 2: Computer Arithmetic 1 BOOK: COMPUTER ORGANIZATION AND DESIGN,3ED, DAVID L. PATTERSON AND JOHN L. HANNESSY, MORGAN KAUFMANN PUBLISHERS Arithmetic Operations 2 Complement Addition Subtraction Multiplication Division Introduction 3 Numbers are represented by binary digits (bits): How are negative numbers represented? What is the largest number that can be represented in a computer world? What happens if an operation creates a number bigger than can be represented? What about fractions and real numbers? A mystery: How does hardware really multiply or divide numbers? Binary Numbers 4 Binary Numbers 5 Binary Number System System Digits: 0 and 1 Bit (short for binary digit): A single binary digit LSB (least significant bit): The rightmost bit MSB (most significant bit): The leftmost bit Upper Byte (or nybble): The right-hand byte (or nybble) of a pair Lower Byte (or nybble): The left-hand byte (or nybble) of a pair Binary Numbers 6 Binary Equivalents 1 Nybble (or nibble) = 4 bits 1 Byte = 2 nybbles = 8 bits 1 Kilobyte (KB) = 1024 bytes 1 Megabyte (MB) = 1024 kilobytes = 1,048,576 bytes 1 Gigabyte (GB) = 1024 megabytes = 1,073,741,824 bytes Binary Numbers 7 Base 2 Binary Addition 8 Rules of Binary Addition 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0, and carry 1 to the next more significant bit Example: 26 +12 Carry Binary Subtraction 9 Rules of Binary Subtraction 0 - 0 = 0 0 - 1 = 1, and borrow 1 from the next more significant bit 1 - 0 = 1 borrowed 1 - 1 = 0 Example: 37 -17 Binary Multiplication 10 Rules of Binary Multiplication 0 x 0 = 0 0 x 1 = 0 1 x 0 = 0 1 x 1 = 1, and no carry or borrow bits Example: 23 x 3 Another Method: Binary multiplication is the same as repeated binary addition
Description: