You are on page 1of 45

UNIVERSITY OF GONDAR

INSTITUTE OF TECHNOLOGY
Department of Electrical and Computer Engineering

course name: digital logic design


course code: ECEG3141
course instructor: Amare worku
contact information:
email: amareworku2154@gmail.com
consultation hours: Friday: from 8:00-11:00
Binary signed number

 Is either positive or negative number.


 It has two part :- sign and magnitude part.
 There are three form in which the signed whole number representation in binary.
1. Sign magnitude form
2. 2’s complement form
3. 1’s complement form
sign bit
 The left most bit in signed binary number is the sign bit which tells you wether the number is positive or
negative
 A 0 sign bit indicates positive sign number and a 1 sign bit indicates a negative
sign number
Sing magnitude form

 When a signed binary number is represented in sign magnitude form the lf


most bit represent the sign and the remaining bit represent the magnitude.
 Example +25 in sign magnitude form in eight bit
Cont.….

 And the decimal number – 25 is expressed by


1’s complement form

 1’s complement of the positive number is as in the same way as positive sign magnitude
number.
 But the negative number is 1’s complement of the positive number.
 Example 1’s complement of -25 in eight is the 1’s complement of+25(0001101) ;1110010.
2’s complement form

 Positive number in 2’s complement form is represented as sign magnitude form and1’s
complement form and
 the negative number are the 2’s complement of the corresponding positive number.
 Example -25
Decimal value for signed binary number

 In n bit we can represent a number from

 the signed binary number A ,it decimal number is


 A =-2^(n-1)+ 2^i*ai
 Example determine the decimal value for the following signed binary number
 A.0101010100
 B.1100010
 C.1000110
 D.0111101
Arithmetic operation in signed binary number

Addition
Cont.….

 Example
Cont.…
Cont.…

 Discard carry
 Overflow indicator
Cont.…..

 Example perform the following signed binary number


 A.010000000+010000001
 B.100000001+100000010
 C.00101010 + 001010100
 D.00011110+00001111
 E.00001110 +11101111
 F.11111111 + 11111000
subtraction
Cont.…

 Example perform the following signed binary number


a.00001000-00000011
b.00011000-11110111
c.11100111-00010011
d.10001000-11100010
Hexadecimal number

 It has 16 distinct character.


 Written radix of 16.
Cont.…
Binary to hexadecimal conversion

 By grouping the bit binary we can convert binary to hex.


 Example
 A.101010100111111001
 B.0100001110101010111
 C.1110101010100110001
 D.0010100100100111001
Hexadecimal to binary conversion

 Example convert the following hexadecimal number to binary


 A.10A4
 B.CF8E
 C.9742
 D.ABCDE
hexadecimal to decimal conversion

 Example convert the following hexadecimal number to decimal


 We can convert in two way :
 first convert to binary then to decimal ,
 second by direct conversion
 A.1C
 B.A85
 C.578AC
Decimal to hexadecimal conversion

 Example
Example

 Convert the following number to hexadecimal


 A. 127
 B. 234
 C. 89
Hexadecimal addition

 Example add the following hexadecimal number


Hexadecimal subtraction

 Example
Octal number system
Cont.…
Cont.…
Binary to octal conversion
Octal to binary conversion
Binary coded decimal(BCD)

 If each digit of a decimal number is represented by its binary equivalent, the result is a code
called binary-coded-decimal(hereafter abbreviated BCD).
 Since a decimal digit can be as large as 9, four bits are required to code each digit (the binary
code for 9 is 1001).
decimal binary BCD

Cont .… 0 0000 0000


1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
10 1010 00010000
11 1011 00010001
12 1100 00010010
13 1101 00010011
14 1110 00010100
15 1111 00010101
Cont.….

 BCD uses four digit.


 With four bit sixteen number (0000 through)1111 can be represented but in
BCD ten of theses are used.(0-9)
 Invalid code:- the six code combination are not used-
1010,1011,1100,1101,1110 and1111 are invalid number in BCD.
 To express any decimal number in BCD,simply replace each decimal digit
with the appropriate four bit code.
Cont.….

 Example convert the following decimal to BCD number.


Cont.….

 It is equally easy to determine the decimal number from BCD number.


 Start at the right most bit and break in to group of four bit.
 Then write the decimal digit represented by each four bit group.
 Example
cont.….

 Example 2.
 Convert the BCD number 011111001000 to its decimal equivalent.
0111 1100 1000

7 error occurred 8

therefore, the number incorrect in BCD code.


Comparison of BCD and binary

 It is important to realize that BCD is not another number system like


binary,octal,decimal and hexadecimal.
 BCD code convert each decimal code digit to binary individually.
 Example convert 253 to straight binary form and BCD form.
 In BCD 253 =0010 0101 0011
 In straight binary form 253 = 11111101
Digital code

 Many specialized code are used in digital system:-


 BCD = strictly numeric code
 Alphanumeric = letter ,symbol, instruction
 Grey
 ASCII
Grey code

 The Gray code was designed by Frank Gray at Bell Labs and patented in 1953.
 It is an unweighted binary code in which two successive values differ only by 1 bit.
Binary to grey code conversion

 A given binary number can be converted into its Gray code equivalent by going through
the following steps:
 1. Begin with the most significant bit (MSB) of the binary number. The MSB of the Gray
code equivalent is the same as the MSB of the given binary number.
 2. The second most significant bit, adjacent to the MSB, in the Gray code number is
obtained by adding the MSB and the second MSB of the binary number and ignoring the
carry, if any. That is, if the MSB and the bit adjacent to it are both ‘1’, then the
corresponding Gray code bit would be a‘0’.
 3. The third most significant bit, adjacent to the second MSB, in the Gray code number is
obtained by adding the second MSB and the third MSB in the binary number and ignoring
the carry, if any.
Cont.…

 4. The process continues until we obtain the LSB of the Gray code number by the addition of the LSB and the next
higher adjacent bit of the binary number.
 The conversion process is further illustrated with the help of an example showing step-by-step
 conversion of (1011)
 into its Gray code equivalent:
 Binary 1011
 Gray code 1---
 Binary 1011
 Gray code 11- -
 Binary 1011
 Gray code 111-
 Binary 1011
 Gray code 1110
Cont.….
Grey to binary conversion

 A given Gray code number can be converted into its binary equivalent by going through the
following steps:
 1. Begin with the most significant bit (MSB). The MSB of the binary number is the same as
the MSB of the Gray code number.
 2. The bit next to the MSB (the second MSB) in the binary number is obtained by adding
the MSB in the binary number to the second MSB in the Gray code number and
disregarding the carry, if any.
 3. The third MSB in the binary number is obtained by adding the second MSB in the binary
number to the third MSB in the Gray code number. Again, carry, if any, is to be ignored.
 4. The process continues until we obtain the LSB of the binary number.
Cont.….
ASCII code

 The ASCII (American Standard Code for Information Interchange), pronounced ‘ask-ee’,
 is strictly a seven-bit code based on the English alphabet.
 ASCII codes are used to represent alphanumeric data in computers, communications equipment and
other related devices.
 Since it is a seven-bit code, it can at the most represent 128 characters.
 It currently defines 95 printable characters including 26 upper-case letters (A to Z),
 26 lower-case letters (a to z),
 10 numerals (0 to 9) and
 33 special characters including mathematical symbols, punctuation marks and space character.
Cont.…
Cont.….

You might also like