De Lecture - 02
De Lecture - 02
Binary Number
1’s Complement
• The 1's complement of any binary number is
performed by simply changing all 1's into 0's
and 0's into 1's, i.e. each bit is replaced by its
complement.
Binary number 1's complement
1011 0100
010101 101010
1100.01 0011.10
10010.110 01101.001
2’s Complement
Solution
Given binary number = 1010
1's complement of 1010 = 0101
+1
0110
2's complement of 1010 = 0110
Example:
Find the 2's complement of the (11.01)2
Solution
Given binary number = 11.01
1's complement of 11.01 = 00.10
+1
00.11
2's complement of 11.01 = 00.11
Binary number: 1010 1111 11.01
2’s complement: 0110 0001 00.11
0+0=0
0+1=1
1+0=1
1 + 1 = 10, i.e. 0 with a carry of 1
Example: Add the binary numbers
1101.101 and 111.011
Solution
2. Binary Subtraction
The rules of binary subtraction are the
following:
0-0=0
0 - 1 = 1, with a borrow of 1
1-0=1
1-1=0
Example: Subtract the binary number 101
from 1011
Solution
3. Binary Multiplication
The rules of binary multiplication are the
following:
0×0=0
0×1=0
1×0=0
1×1=1
Example: Multiply the binary number 1101
by 110
Solution
4. Binary Division
Example: Divide the binary number 11010 by
101
Solution
Rules of Binary Arithmetic
Binary Arithmetic using 1’s
and 2’s Complements
Logic for Binary Arithmetic
The binary arithmetic operation can be written
as:
A+B=A+B
A – B = A + (-B)
- A + B = (-A) + B
- A – B = (-A) + (-B)
The negative binary number can be represented
either 1’s or 2’s complement form.
Binary Arithmetic using 1’s
Complements
Example-1: Subtract 14 from 25 using 1’s
complement method.
Example-2: Add -25 to 14 using 1’s
complement method.
Example-3: Add -14 to -25 using 1’s
complement method.
Example-4: Add 14 to 25 using 1’s
complement method.
Binary Arithmetic using 2’s
Complements
Example-1: Subtract 14 from 46 using 2’s
complement method.
Example-2: Add -75 to 26 using 2’s
complement method.
Example-3: Add -14 to -25 using 2’s
complement method.
Floating-Point Number
Representation
• Floating-Point is useful for representing a
number in a wide range: very small to very
large.
• It is widely used in the scientific world.
• There are many ways to write a number in
scientific notation, but there is always a
unique normalized representation, with
exactly one non-zero digit to the left of the
point.
Example:
257 = 25.7 × 101 = 2.57 × 102 = …
0.232 × 103 = 2.32 × 102 = 23.2 × 101 = …
01001 = 1.001 × 23 = ...
• What’s the normalized representation of
00101101.101 ?
00101101.101 = 1.01101101 × 25
= 1 × (1.00111000000000000000000) × 24
= 1.00111000000000000000000 × 24
= 10011.10
= 19.5
Example: Find out the floating point number
from the following representation.
1 1000 0001 011 0000 0000 0000 0000 0000
1 1000 0001 011 0000 0000 0000 0000 0000
E = 100000012 = 129
N = (-1)S × (1 + F) × 2E-bias
= (-1)1 × (1.01100000000000000000000) × 2129-127
= - 1 × (1.01100000000000000000000) × 2 2
= - 1.01100000000000000000000 × 2 2
= - 101.10
= - 5.5