01 Week01 IntroductionAndNumberSystem
01 Week01 IntroductionAndNumberSystem
Design
2
Class Policy
• No Re-take of any of the Quiz, HW
or any other assessment
• 75% attendance is required to
appear in Final Exam
Text Books
2 19 10011 2 29 11101
2 91 2 14 1
2 41 2 07 0
2 20 2 03 1
10
11
Conversion
Binary to Decimal:
Convert to Decimal
11101
4 3 2 1 0
1x2 + 1x2 + 1x2 + 0x2 + 1x2
16 + 8 + 4 + 0 + 1 = 29
( 11101 ) 2 = ( 29 ) 10
Magnitude of a
102=100 101=10 100=1
Decimal Number
Weights
2 6 3 Factors
3x1 =3
11101
4 3 2 1 0
1x2 + 1x2 + 1x2 + 0x2 + 1x2
16 + 8 + 4 + 0 + 1 = 29
( 11101 ) 2 = ( 29 ) 10
210=1024 29=512 28=256 27=128 26=64 25=32 24=16 23=8 22=4 21=2 20=1 Weights
b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 bn=0 or 1
Factors
20 1
21 2 In case of binary numbers the Factors are either 0 or 1.
22 4
• If 0, after multiplying with weight, it would become 0.
23 8
24 16 • If 1, after multiplying with weight, it would be equal to weight.
25 32
26 64 22=4 21=2 20=1 Weights
27 128 1 0 1 Factors
2 8
256
1x1 =1
29 512
210 1024
0x2 =0 5 ( 101 )2= ( 5 )10
1x4 =4
Conversion
Binary to Decimal:
Convert to Decimal
11101 11101
4 3 2 1 0
1x2 + 1x2 + 1x2 + 0x2 + 1x2
16 + 8 + 4 +
2 + 1
1x16 + 1x8 + 1x4 + 0x2 + 1x1 =29
16 + 8 + 4 + 0 + 1 = 29
( 11101 ) 2 = ( 29 ) 10
Conversion
Binary to Decimal:
Convert to Decimal
1110110
64 + 32 + 16 +
8 +4 +2 +
1
=118
( 1110110 ) 2 = ( 118 ) 10
Conversion
Decimal to Binary:
Convert to binary
Weights
64 32 16 8 4 2 1
2 14 1
2 07 0
2 03 1
11
Decimal to Binary:
Convert to binary
128 64 32 16 8 4 2 1
4205
3 2 1 0
4x8 + 2x8 + 0x8 + 5x8
16 274 6 6
16 17 2 16 8646 7 7
16 540 6 21C6 8 8
11 9 9
16 33 12=C 10 A
21 11 B
112 12 C
13 D
14 E
15 F
Conversion Decimal Hex
Hex to Decimal: 0 0
Convert to Decimal 1 1
2 2
3 3
21C6 4 4
5 5
3 2 1 0
2x16 + 1x16 + Cx16 + 6x16 6 6
7 7
8 8
2x4096 + 1x256 + 12x16 + 6x1 9 9
10 A
8192 + 256 + 192 + 6 = 8646 11 B
12 C
( 21 C 6 ) 16 = ( 8646 ) 10 13
14
D
E
15 F
Conversion
Octal to Binary
1.Octal Decimal Binary Decimal Octal Binary
2.Directly: Octal Binary 0 0 0 0 0
1 1 0 0 1
Covert 2 2 0 1 0
3 3 0 1 1
4 4 1 0 0
3406 5 5 1 0 1
6 6 1 1 0
7 7 1 1 1
011 100 000 110
011100000110
( 3406 )8 = ( 11100000110 ) 2
Conversion
Binary to Octal
1.Binary Decimal Octal Decimal Hex Binary
2.Directly: Binary Octal 0 0 0 0 0
1 1 0 0 1
Convert to Octal 2 2 0 1 0
3 3 0 1 1
4 4 1 0 0
5 5 1 0 1
6 6 1 1 0
10111011010111 7 7 1 1 1
1 1
11010
11011
110101
Basic Arithmetic Operations
In Binary Number System
10 Decimal Binary
0 1 1 0 0 0 0
-0 -1 -0 -1 1 0 1
2 1 0
0 0 1 1(With 1 Borrow) 3 1 1
10 1
0 0 10 10
1 1 0 0 1
0 1 0 1 0
0 1 1 1 1
Decimal Octal Hex Binary
Base: 10 Base: 8 Base: 16 Base: 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1
0 0 0 2 0 0 0 2 0 0 0 2 0 0 0 1 0
0 0 0 3 0 0 0 3 0 0 0 3 0 0 0 1 1
0 0 0 4 0 0 0 4 0 0 0 4 0 0 1 0 0
0 0 0 5 0 0 0 5 0 0 0 5 0 0 1 0 1
0 0 0 6 0 0 0 6 0 0 0 6 0 0 1 1 0
0 0 0 7 0 0 0 7 0 0 0 7 0 0 1 1 1
0 0 0 8 0 0 1 0 0 0 0 8 0 1 0 0 0
0 0 0 9 0 0 1 1 0 0 0 9 0 1 0 0 1
0 0 1 0 0 0 1 2 0 0 0 A 0 1 0 1 0
0 0 1 1 0 0 1 3 0 0 0 B 0 1 0 1 1
0 0 1 2 0 0 1 4 0 0 0 C 0 1 1 0 0
0 0 1 3 0 0 1 5 0 0 0 D 0 1 1 0 1
0 0 1 4 0 0 1 6 0 0 0 E 0 1 1 1 0
0 0 1 5 0 0 1 7 0 0 0 F 0 1 1 1 1
0 0 1 6 0 0 2 0 0 0 1 0 1 0 0 0 0
0 0 1 7 0 0 2 1 0 0 1 1 1 0 0 0 1
0 0 1 8 0 0 2 2 0 0 1 2 1 0 0 1 0
0 0 1 9 0 0 2 3 0 0 1 3 1 0 0 1 1
0 0 2 0 0 0 2 4 0 0 1 4 1 0 1 0 0
Decimal Octal Hex Binary
Base: 10 Base: 8 Base: 16 Base: 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
For
0 1
the Example0
shown
0 0
below:
1
Note
0
that:
0 0 1 0 0 0 0 1
0 0
•0 The
2
Decimal
0 0
Number:
0 2
• 0The 0Decimal
0 2
Number: 0 0 0 1 0
0 0 0 3 0 0 0 3 0 0 0 3 0 0 0 1 1
0 0 •0 The
4 0 0 0 4 • 0The 0Octal0 4 0 0 1 0 0
Octal Number: Number:
0 0 0 5 0 0 0 5 0 0 0 5 0 0 1 0 1
0 0 •0 The
6 Hex Number:
0 0 0 6 • 0The 0Hex0Number:
6 0 0 1 1 0
0 0 0 7 0 0 0 7 0 0 0 7 0 0 1 1 1
0 0 •0 The
8 Binary Number:
0 0 1 0 • 0The 0Binary
0 Number:
8 0 1 0 0 0
0 0 0 9 0 0 1 1 0 0 0 9 0 1 0 0 1
0 0 1 0 0 0 1 2 0 0 0 A 0 1 0 1 0
0 0 1 1 0 0 1 3 0 0 0 B 0 1 0 1 1
0 0 =1 ==2 0 0 1 4 0 0 0 C 0 1 1 0 0
0 0 1 3 0 0 1 5 0 0 0 D 0 1 1 0 1
0 0 1 4 0 0 1 6 0 0 0 E 0 1 1 1 0
0 0 1 5 0 0 1 7 0 0 0 F 0 1 1 1 1
0 0 1 6 0 0 2 0 0 0 1 0 1 0 0 0 0
0 0 1 7 0 0 2 1 0 0 1 1 1 0 0 0 1
0 0 1 8 0 0 2 2 0 0 1 2 1 0 0 1 0
0 0 1 9 0 0 2 3 0 0 1 3 1 0 0 1 1
0 0 2 0 0 0 2 4 0 0 1 4 1 0 1 0 0
What is meant by Signed
Numbers ?
• So far, we have not considered the sign of the
numbers. So, by default the numbers are
Positive.
• What if we have to save a negative number?
• For example, binary equivalent of 20 (in
decimal) is 10100. So is the binary equivalent
of -20 as -10100?
• How to save negative sign in a Digital Device?
• Basically, there is a concept of Complement
of a number (in any number system) to
represent a negative number and there is no
need for the negative sign.
Complement of a Number
• Complement of a positive number represents
the negative of that number (without the
negative sign).
1’s complement: To take 1’s complement of a binary number, simply invert all the bits.
Example:
001110
Find 2’s complement of 1001000
0111000
Signed and Unsigned Numbers
LSB and MSB: Decimal Binary Unsigned Signed
In n-bit number, the right most bit MSB LSB
0 0 0 0 0 0 0
is the LSB and left most is MSB. 1 0 0 0 1 1 1
2 0 0 1 0 2 2
3 0 0 1 1 3 3
Unsigned Notation: 4 0 1 0 0 4 4
All Numbers are positive. 5 0 1 0 1 5 5
6 0 1 1 0 6 6
7 0 1 1 1 7 7
Signed Notation: 8 1 0 0 0 8 -8
Half are Positive and Half are Negative 9 1 0 0 1 9 -7
10 1 0 1 0 10 -6
11 1 0 1 1 11 -5
How to find the –ve number? 12 1 1 0 0 12 -4
13 1 1 0 1 13 -3
14 1 1 1 0 14 -2
15 1 1 1 1 15 -1
Signed and Unsigned Numbers
• MSB=0 Positive Number (with magnitude Decimal Binary Unsigned Signed
same as the Unsigned Notation
MSB LSB
• MSB=1 Negative Number (How to find the 0 0 0 0 0 0 0
value??) 1 0 0 0 1 1 1
• Is 11010 a Positive Number or Negative 2 0 0 1 0 2 2
Number (in Signed Notation)? 3 0 0 1 1 3 3
• What about 011010? 4 0 1 0 0 4 4
• Is not 11010 and 011010 both Same? 5 0 1 0 1 5 5
6 0 1 1 0 6 6
• Firstly, we have to decide (and fix) the size of 7 0 1 1 1 7 7
the number (number of bits), then we can 8 1 0 0 0 8 -8
declare a bit as MSB. 9 1 0 0 1 9 -7
• If we have 5-Bit number, then 11010 has MSB 10 1 0 1 0 10 -6
as 1 and we cannot add a zero on leftmost 11 1 0 1 1 11 -5
position. And the number is a negative 12 1 1 0 0 12 -4
13 1 1 0 1 13 -3
number.
14 1 1 1 0 14 -2
• If we have a 6-Bit number, then 11010 in 6-Bit 15 1 1 1 1 15 -1
is 011010 and it is a Positive Number.
Signed and Unsigned Numbers
• MSB=0 Positive Number (with magnitude Decimal Binary Unsigned Signed
same as the Unsigned Notation
MSB LSB
• MSB=1 Negative Number (How to find the 0 0 0 0 0 0 0
value??) 1 0 0 0 1 1 1
2 0 0 1 0 2 2
3 0 0 1 1 3 3
4 0 1 0 0 4 4
5 0 1 0 1 5 5
6 0 1 1 0 6 6
7 0 1 1 1 7 7
8 1 0 0 0 8 -8
9 1 0 0 1 9 -7
10 1 0 1 0 10 -6
11 1 0 1 1 11 -5
12 1 1 0 0 12 -4
13 1 1 0 1 13 -3
14 1 1 1 0 14 -2
15 1 1 1 1 15 -1
Range of numbers in n-bit Systems
Unsigned Notation: Decimal Binary Unsigned Signed
n-bits : 0
MSB
0 0 0
LSB
0 0 0
• Total 2n different numbers 1
2
0
0
0
0
0
1
1
0
1
2
1
2
• 0 to 2n -1 3
4
0
0
0
1
1
0
1
0
3
4
3
4
5 0 1 0 1 5 5
6 0 1 1 0 6 6
• Represent (40) in 6-Bit Binary Number 7 0 1 1 1 7 7
using Unsigned Notation 8
9
1
1
0
0
0
0
0
1
8
9
-8
-7
10 1 0 1 0 10 -6
11 1 0 1 1 11 -5
12 1 1 0 0 12 -4
• Represent (40) in 5-Bit Binary Number 13 1 1 0 1 13 -3
using Unsigned Notation 14 1 1 1 0 14 -2
15 1 1 1 1 15 -1
Range of numbers in n-bit Systems
Signed Notation: Decimal Binary Unsigned Signed
n-bits : MSB LSB
• 0 0 0 0 0 0 0
Total 2n different numbers
1 0 0 0 1 1 1
• Half +ve and Half –ve 2 0 0 1 0 2 2
• Half is 2n /2 = 2n-1 3 0 0 1 1 3 3
• +ve= 0 to 2n-1 -1 4 0 1 0 0 4 4
5 0 1 0 1 5 5
• -ve = -1 to -2n-1 6 0 1 1 0 6 6
• Represent (-40) in 6-Bit Binary 7 0 1 1 1 7 7
Number using signed Notation 8 1 0 0 0 8 -8
9 1 0 0 1 9 -7
10 1 0 1 0 10 -6
11 1 0 1 1 11 -5
12 1 1 0 0 12 -4
• Represent (-40) in 7-Bit Binary 13 1 1 0 1 13 -3
Number using signed Notation 14 1 1 1 0 14 -2
15 1 1 1 1 15 -1
Does 2’s Complement actually represents a –ve
number? Decimal Binary Unsigned Signed
In Decimal Numbers: 0
MSB
0 0 0
LSB
0 0 0
1 0 0 0 1 1 1
2 0 0 1 0 2 2
3 0 0 1 1 3 3
4 0 1 0 0 4 4
In Binary Numners: 5
6
0
0
1
1
0
1
1
0
5
6
5
6
7 0 1 1 1 7 7
8 1 0 0 0 8 -8
9 1 0 0 1 9 -7
10 1 0 1 0 10 -6
11 1 0 1 1 11 -5
0110 12 1 1 0 0 12 -4
13 1 1 0 1 13 -3
1100 14 1 1 1 0 14 -2
15 1 1 1 1 15 -1
10010
How does a computer know to treat a number as
Signed or Unsigned?
Decimal Binary Unsigned Signed
Unsigned Signed MSB LSB
0 0 0 0 0 0 0
1010 10 -6 1 0 0 0 1 1 1
2 0 0 1 0 2 2
+ 0010 2 2 3 0 0 1 1 3 3
4 0 1 0 0 4 4
5 0 1 0 1 5 5
1100 12 -4 6 0 1 1 0 6 6
7 0 1 1 1 7 7
8 1 0 0 0 8 -8
9 1 0 0 1 9 -7
10 1 0 1 0 10 -6
11 1 0 1 1 11 -5
12 1 1 0 0 12 -4
13 1 1 0 1 13 -3
14 1 1 1 0 14 -2
15 1 1 1 1 15 -1
BCD (Binary Coded Decimal) Numbers
HEX Binary Decimal BCD
Hex to Binary
00 00000 0 0 0 0 0 0
21C6 01 00001 1 0 0 0 0 1
02 00010 2 0 0 0 1 0
03 00011 3 0 0 0 1 1
0010 0001 1100 0110 (0010 0001 1100 0110)2 04 00100 4 0 0 1 0 0
05 00101 5 0 0 1 0 1
06 00110 6 0 0 1 1 0
07 00111 7 0 0 1 1 1
Decimal to BCD 08 01000 8 0 1 0 0 0
3974 09
0A
01001 9
0 1 0 1 0 10
0
1
1 0 0
0 0 0
1
0
0B 0 1 0 1 1 11 1 0 0 0 1
0011 1001 0111 0100 (0011 1001 0111 0100)BCD 0C 0 1 1 0 0 12 1 0 0 1 0
0D 0 1 1 0 1 13 1 0 0 1 1
0E 0 1 1 1 0 14 1 0 1 0 0
0F 0 1 1 1 1 15 1 0 1 0 1
10 1 0 0 0 0 16 1 0 1 1 0
11 1 0 0 0 1 17 1 0 1 1 1
12 1 0 0 1 0 18 1 1 0 0 0
13 1 0 0 1 1 19 1 1 0 0 1
14 1 0 1 0 0 20 1 0 0 0 0
BCD (Binary Coded Decimal) Numbers
Decimal Binary Decimal BCD
BCD to Decimal: 00 00000 0 0 0 0 0 0
01 00001 1 0 0 0 0 1
0100 0110 1000 0101 02 00010 2 0 0 0 1 0
03 00011 3 0 0 0 1 1
04 00100 4 0 0 1 0 0
05 00101 5 0 0 1 0 1
06 00110 6 0 0 1 1 0
07 00111 7 0 0 1 1 1
08 01000 8 0 1 0 0 0
09 01001 9 0 1 0 0 1
0110 1100 1001 NOT a Valid BCD Number 10 0 1 0 1 0 10 1 0 0 0 0
11 0 1 0 1 1 11 1 0 0 0 1
12 0 1 1 0 0 12 1 0 0 1 0
13 0 1 1 0 1 13 1 0 0 1 1
14 0 1 1 1 0 14 1 0 1 0 0
15 0 1 1 1 1 15 1 0 1 0 1
16 1 0 0 0 0 16 1 0 1 1 0
17 1 0 0 0 1 17 1 0 1 1 1
18 1 0 0 1 0 18 1 1 0 0 0
19 1 0 0 1 1 19 1 1 0 0 1
20 1 0 1 0 0 20 1 0 0 0 0
BCD (Binary Coded Decimal) Numbers
Decimal Binary Decimal BCD
BCD Calculation
00 00000 0 0 0 0 0 0
01 00001 1 0 0 0 0 1
0111 0101 0101 0101 0010 552 02 00010 2 0 0 0 1 0
+0001 0010 +0001 0110 0011 163 03 00011 3 0 0 0 1 1
04 00100 4 0 0 1 0 0
1000 0111 0110 1011 0101 715 05 00101 5 0 0 1 0 1
+ 0110 06 00110 6 0 0 1 1 0
07 00111 7 0 0 1 1 1
0111 0001 0101 08 01000 8 0 1 0 0 0
09 01001 9 0 1 0 0 1
10 0 1 0 1 0 10 1 0 0 0 0
11 0 1 0 1 1 11 1 0 0 0 1
0110 0100 0011 643 12 0 1 1 0 0 12 1 0 0 1 0
-0100 1001 0010 492 13 0 1 1 0 1 13 1 0 0 1 1
14 0 1 1 1 0 14 1 0 1 0 0
0001 1011 0001 151 15 0 1 1 1 1 15 1 0 1 0 1
-0110 16 1 0 0 0 0 16 1 0 1 1 0
17 1 0 0 0 1 17 1 0 1 1 1
0001 0101 0001 18 1 0 0 1 0 18 1 1 0 0 0
19 1 0 0 1 1 19 1 1 0 0 1
20 1 0 1 0 0 20 1 0 0 0 0
Other Decimal
Codes
Gray Code
ASCII Codes
A parity bit is an extra bit included with
Error‐Detecting
a message to make the total number of
Code (Parity Bit) 1’s either even or odd.