Escolar Documentos
Profissional Documentos
Cultura Documentos
University Of Sharjah
One characteristic of digital system is their ability to manipulate discrete elements of information The signals in most present day electronic digital system use just two discrete values and said to be Binary A Binary Digit is called a Bit A Bit has two values: 0 or 1
University Of Sharjah
A group of bits can be made to represent discrete symbols A digital system is a system that manipulates discrete elements of information that is represented internally in Binary format Most digital devices are programmable Digital system manipulates discrete quantities of information that are represented in binary form
University Of Sharjah Dr. Mouna Nakkar & Dr. Ali El-Moursy 3
Base 2: Bnary: 0, 1 Base 8: Octal: 0, 1, 2, 3, 4, 5, 6, 7 Base 10: Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 16: Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , A, B, C, D, E, F
University Of Sharjah
Octal (Base 8)
0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17
A decimal number of 7,392 represents a quantity equal to 7 thousand, plus 3 hundreds, plus 9 tens, plus 2 units 7 X 103 + 3 X 102 + 9 X 101 + 2 X 100 In more general terms a5a4a3a2a1a0.a-1a-2a-3 =105 a5 + 104 a4 + 103 a3 + 102 a2 + 101 a1 + 100 a0 + 10-1 a-1 + 10-2 a-2 + 10-3 a-3
University Of Sharjah Dr. Mouna Nakkar & Dr. Ali El-Moursy 7
The Binary system is a different number system. The coefficients of the Binary number system have only two possible values: 0 and 1. Each coefficient ai is a multiple of 2i
University Of Sharjah
General Rules:
A number expressed in a baser system has coefficients multiplied by power of r an . rn + an-1. rn-1 + ..+ a2 . r2 + a1 . r1 + a0 + a-1. r-1 + a-2 -m 2 . r + .. + a-m . r
University Of Sharjah
Convert from any base to decimal. Convert from decimal to any base. Convert from any base to any base.
University Of Sharjah
10
Example,
(11010.11)2 is a binary number
University Of Sharjah
11
Exercise:
What is the equivalent decimal number for (4021.2)5 ; a number is given in base 5
What is the equivalent decimal number for (127.4)8 ; a number given in base 8
University Of Sharjah
12
Exercise:
What is the equivalent decimal number for (B65F)H ; a number is given in base 16
What is the equivalent decimal number for (110101)2 ; a number given in base 2
University Of Sharjah
13
Suppose we want to convert a number in base 10 to binary or other bases. What do we do?
University Of Sharjah
14
Divide the decimal by 2 until we reach a 0 The reminder is the new binary number Reminder 1 0 0 1 0 1
Dr. Mouna Nakkar & Dr. Ali El-Moursy 15
41 2 20 2 10 2 5 2 2 2 1 2 0
University Of Sharjah
(41)d = (101001)2
Example:
Convert decimal 153 to Octal
Reminder 153 8 19 8 2 8 0 1 3 2
(153)d = (231)8
University Of Sharjah
16
1 0 1 1
(0.6875)d = (0.1011)2
Example,
Convert (0.513)10 to Octal
Whole Number 0.513 X8 0.104 X8 0.832 X8 0.656 X8 0.248
University Of Sharjah
4 0 6 5 1
Dr. Mouna Nakkar & Dr. Ali El-Moursy 18
(0.513)d = (0.406517)8
Group the n bits of Binary and directly converting them Q: Convert the following Binary to Octal & Hex (10110001101011.111100000110)2 A: Group each three bits and find their Octal equivalence (26153.7406)8 A: Group each four bits and find their Hex equivalence (2C6B.F06)H
Example:
University Of Sharjah
19
equivalence
Example:
Convert the following Octal Number to its Binary (673.124)8 = (110 111 011.001010100)2 Convert the following Hex Number to its Binary (306.D)H = (0011 0000 0110. 1101)2
University Of Sharjah
20
14/2 =5
University Of Sharjah
21
54/4 = 13
7 + 12 = 19
University Of Sharjah
22
There are two types of complements for each base-r system: the radix complement and the diminished radix complement. rs complement: Radix Complement (r-1)s complement: Diminished Radix Complement
University Of Sharjah
23
University Of Sharjah
24
1s complement 1011000 is
2.
1s complement 0101101 is
Radix Complement:
10s complement is 9s complement +1 2s complement is 1s complement +1
Example:
10s complement of 2389 = 9999 ----------7610 1 - 2389
+ 2s complement of 1101101 is
0010010 + 1 ----------------0010011
Hint: for 2s complement, leave all significant 0s unchanged until the first 1 and then flip each 0 to 1 and each 1 to 0
University Of Sharjah
26
University Of Sharjah
27
RULE:
1. 2.
Add M to the rs complement of N M + (rn N) = M N + rn If M > N , the sum will produce an end carry, rn, which can be discarded If M < N, the sum does not produce an end carry and is equal to rn (N-M) which is the rs complement of (N M). To obtain the answer in a familiar form, take the rs complement of the sum.
3.
University Of Sharjah
28
University Of Sharjah
29
Exercise:
Using 10s complement perform the subtraction 3250 72532
University Of Sharjah
30
Exercise:
University Of Sharjah
31
Signed:
Some positive and some negative
University Of Sharjah
32
Usually a negative numbers are represented by () minus sign In computer language this is really hard To represent a negative number assign the Most Significant Bit (MSB) to 1. If MSB is = 0, then the number is positive If MSB is = 1, then the number is negative
University Of Sharjah
33
There are many representations for the signednumbers in binary. Most popular ones are:Signed-magnitude representation Signed-2s-complement representation
In ALL presentations MSB SHOULD be:1 for negative numbers 0 for positive numbers
It is used in some ordinary arithmetic operations but not in the computer arithmetic
N bits 1 bit N-1 bits
Sign bit
Magnitude bits
Represent decimal 5 & -5 in 4-bits signedmagnitude (5)10 -> (0101)2 (-5)10 -> (1101)2
University Of Sharjah Dr. Mouna Nakkar & Dr. Ali El-Moursy 35
Signed Magnitude
0111 0110 0101 0100 0011 0010 0001 0000 1001 1010 1011 1100 1101 1110 1111 ----36
0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000
Exercise:
find the decimal for the following 8-bit signed binary number in signed-2scomplement representation (10110010)2 (11110110)2 (00110010)2
University Of Sharjah
37
University Of Sharjah
38
Overflow occurs when we start with n-bits and the result occupies n+1 bits. We just add another 0 to a positive number or another 1 to a negative number in the mostsignificant position to extend them to n+1 bits and then perform the addition.
University Of Sharjah
39
If the Carry-in to the MSB (sign bit) is different than the carry-out of MSB (sign bit), then there is an overflow
University Of Sharjah
40
Exercise: perform the following addition (signed numbers) +6 0000 0110 +13 0000 1101 --------------------+6 0000 0110 -13 1111 0011 ---------------------6 1111 1010 +13 0000 1101 ---------------------6 1111 1010 -13 1111 0011 ---------------------
University Of Sharjah
41
An n-bit Binary Code is a group of n bits that assume 2n distinct combination If n = 2, 22 =4 distinct combinations If n = 3, 23 = 8 distinct combinations If n = 4, 24 = 16 distinct combinations
University Of Sharjah
42
0 1 2 3 4 5 6 7 8 9
43
ASCII Codes: American Standard Code of Information Interchange Uses seven bits to code 128 character Look book page 23
University Of Sharjah
44
University Of Sharjah
45
Binary Logic is based on Binary System Holds one of two values: 0 and 1 (true, false) (yes, no)..etc Def:
Variables A,B,C, y,y,z etc. These variables can hold one of two values: 0, 1 Three basic logical operations: AND, OR, NOT
University Of Sharjah
46
1.
2.
3.
AND: represented by . x . y = z or xy = z z = 1 if and only if both x=1 and y=1 otherwise z=0 OR: represented by + x+y=z z = 1 if either x=1 or y = 1 otherwise z=0 NOT: x = z z= 1 if x = 0 other wise z=0
University Of Sharjah
47
AND
x 0 0 1 1 y 0 1 0 1 xy 0 0 0 1 x 0 0 1 1
OR
y 0 1 0 1 x+y 0 1 1 1 x 0 1
NOT
x 1 0
University Of Sharjah
48
2-input AND gate 2-input OR gate Not gate 3-input AND gate 3-input OR gate
University Of Sharjah
49