Lecture 2
Lecture 2
Lecture 2
Binary Arithmetic
• Binary arithmetic is a system of mathematics used in digital circuits,
like computers, which operate on binary digits, commonly known as
bits.
• Information in computers is stored in binary form. Knowledge of
binary arithmetic is essential for understanding how data is
represented, manipulated, and processed in computers.
Binary Arithmetic
• The basic operations in binary arithmetic include
1. Addition
2. Subtraction
3. Multiplication
4. Division
Binary Addition
Rules for Addition
0+0=0
0+1=1
1+0=1
1 + 1 = 10 ( we will write 0 and carry 1 to the next column)
1 + 1 +1 = 11 (we will write 1 and carry 1 to the next column)
Binary Addition (Examples)
Binary Subtraction
• The four basic rules for subtracting bits are as follows:
0-0=0
1-1=0
1-0=1
10 - 1 = 1
When subtracting numbers, you sometimes have to borrow from the next column
to the left. A borrow is required in binary only when you try to subtract a 1 from
a 0. In this case, when a 1 is borrowed from the next column to the left, a 10 is
created in the column being subtracted, and the last of the four basic rules just
listed must be applied.
Binary Subtraction (Example)
Binary Multiplication
• The four basic rules for multiplying bits are as follows:
0×0=0
0×1=0
1×0=0
1×1=1
Multiplication is performed with binary numbers in the same manner
as with decimal numbers. It involves forming partial products, shifting
each successive partial product left one place, and then adding all the
partial products.
Binary Multiplication Examples
Binary Division
• Division in binary follows the same procedure as division in decimal
system.
Binary Number Representation
Binary number
Representation
Only for +ve numbers For +ve and -ve numbers
• For negative numbers the sign bit is always 1, and for positive
number it is always 0
Representation of Signed Numbers
• There are two ways of representing negative binary numbers:
1. Sign Magnitude Form
2. Complement Method
Sign-Magnitude Form
• For n bit binary number, 1 bit is reserved for sign symbol.
• The leftmost bit (MSB) is the sign bit (o is for + and 1 is for -) and the
remaining bits hold the absolute magnitude of the number.
• Example: For the 8 bit
• -47 = 1 0 1 0 1 1 1 1
• +47 = 0 0 1 0 1 1 1 1
Complements
• Complements are used in digital computers to simplify the
subtraction operation and for logical manipulation. Simplifying
operations leads to simpler, less expensive circuits to implement the
operations.
• For example instead of having separate circuit for addition and
subtraction, only addition circuits are required
Complements
• Given a number in r base system then, there are two types of
complements in each base system
1. r’s complements ( Radix complement)
2. (r-1)’ complements ( Diminished Radix complement)
When the value of the base r is substituted in the name, the two types
are referred to as the 2’s complement and 1’s complement for binary
numbers and the 10’s complement and 9’s complement for
decimal numbers.
Diminished Radix Complement (for decimal
System)
• Diminished radix complement, is defined as (𝑟 𝑛 - 1) - N. For decimal
numbers, r = 10
• and r - 1 = 9, so the 9’s complement of N is (10𝑛 - 1) - N. where n is
the number of bits in the N number
• The 9’s complement of 546700 is (106 - 1) – 546700= 999999 -
546700 = 453299.
• The 9’s complement of 012398 is 999999 - 012398 = 987601
Short method: The 9's complement of a number is calculated by
subtracting each digit of the number by 9.
Radix Complement (for decimal System)
• The r’s complement of an n‐digit number N in base r is defined as
𝑟 𝑛 - N for N≠ 0 and as 0 for N = 0.
For Example the 10’s complement of 40 is rn – N = 102 – 40 = 100 – 40
= 60
• Short method 1: Subtract first non-zero from 10, and all others from
9
• Short method 2: Simply, by adding 1 to its 9's complement we can
get its 10's complement value.