Sie sind auf Seite 1von 30

Digital Design

Lecture 3

NUMBER SYSTEMS, OPERATION AND CODES


Dr. PO Kimtho
Department of Computer Sciences
Norton University (NU)

Signed Numbers
Converting signed binaries to decimals can easily be achieved by
assigning a negative value to the weight of the sign bit and
summing all the weights containing logic 1.

Example : Convert the signed number to decimal


11000110
Column weights: -128 64 32 16 8
1
1 0 0 0
-128 +64
Is this true for both complements?
Which is preferred?

4
1

2 1
1 0

+4 +2

= -58

Solve this..
Determine the decimal values of the following
signed 8-bit data when they are 1s complement and 2s
complement form
(a) 000101112 & 111010002
Answer :

(b) 010101102 & 101010102


Answer :

(c) 000000002 & 111111112


Answer :

Signed Numbers (Range)


Signed Integer Range
If there are n-bits, then there should have
2n numbers where the signed numbers can
range between
-(2n-1) ~ +(2n-1 1)
Example:
A 4-bit signed binary will have 16 different
numbers ranging between

-8 ~ +7

Signed Numbers (Range)


4-bit number
Binary

Unsign

Sign

Binary

Unsign

Sign

0000

1000

-8

0001

1001

-7

0010

1010

10

-6

0011

1011

11

-5

0100

1100

12

-4

0101

1101

13

-3

0110

1110

14

-2

0111

1111

15

-1

What is the range for


8-bit & 16-bit numbers?

Signed Numbers
Arithmetic Operations - Addition
Add the 2 signed numbers and discard any
final carry bit

Example:
11111011 + 11110111
11111011
+ 11110111
Discard carry bit 1 11110010

Signed Numbers (Cont.)


Arithmetic Operations - Subtraction
take the 2s complement of the subtrahend
and add to the minuend
discard any final carry bit

Example:
00001000 00000011
minuend

00001000
- 00000011

subtrahend

00001000
+ 11111101
1 00000101

Discard carry

2s
complement
of
subtrahend

Number System (Hexadecimal)


Base 16 system
Uses digits 0-9 &
letters A,B,C,D,E,F
Groups of four bits
represent each
base 16 digit

Number System (Hex) (Cont.)


Hexadecimal to Decimal Conversion
Convert 3B4F16 to its decimal equivalent:
Hex digits
Positional Values
Products

3
x

B
x

4
x

F
x

163 162 161 160


12288 +2816 + 64 +15

15,18310

Number System (Hex) (Cont.)


Decimal to Hexadecimal Conversion
Convert 83010 to its hexadecimal equivalent:

830 / 16
51 / 16
3 / 16

= 51 R 14
=3R3
=0R3

E in Hex

33E16

Number System (Hex) (Cont.)


Binary to Hexadecimal Conversion
Grouping the binary position in 4-bit groups,
starting from the least significant position.

Number System (Hex) (Cont.)


Binary to Hexadecimal Conversion

Example
Convert 0101011010101110011010102 to hex
using the 4-bit substitution code :

0101 0110 1010 1110 0110 1010

Solve this..
a) Convert hexadecimal number 2316, 8D16
and EB16 to decimal
b) Convert decimal number 5210, 28410 and
289010 to hexadecimal
c) Convert hexadecimal number 3816 and
5C816 to binary
d) Convert binary number 1110 and 10111
to hexadecimal

Numbering System (Octal)

Also known as the Base 8 System


Uses digits 0 - 7
Readily converts to binary
Groups of three (binary) digits can be used to
represent each octal digit
Also uses multiplication and division algorithms for
conversion to and from base 10

Numbering System (Octal) (Cont.)


Octal to Decimal Conversion

Convert 6538 to its decimal equivalent


Octal Digits

82

81

80

Positional Values
Products

384 + 40 + 3

42710

Numbering System (Octal) (Cont.)


Decimal to Octal Conversion
Use the repeated division-by-8 method

Example
Convert 42710 to its octal equivalent
427 / 8
53 / 8
6/8

= 53 R 3
=6R5
=0R6

LSB
MSB

6538

Numbering System (Octal) (Cont.)


Octal to Binary Conversion
Each octal number converts to 3 binary digits

Example
Convert 6538 to binary
6

110 101 011

Substitute
numbers with
3-binary digits

Numbering System (Octal) (Cont.)


Binary to Octal Conversion
Grouping the binary position in groups of 3
starting at the least significant position.

Example
Convert the binary numbers 110101 to octal

1 1 0 1 0 1
6

658

Solve this..
a) Convert octal number 648, 5578 and
10248 to decimal
b) Convert decimal number 4610, 10010 and
21910 to octal
c) Convert octal number 1018 and 3218 to
binary
d) Convert binary number 101010 and
110111 to octal

Digital Codes

The essence of computing is Logic High or Logic


Low

Streams of binary data enable codes to be


created to help computers rapidly perform tasks
00110100111101010100011100111001010

BCD, ASCII, EBCDIC, GRAY

Digital Codes - BCD

BCD (Binary Coded Decimal) Code


Represent each of the 10 decimal digits (0~9) as a 4-bit
binary code.

Example
Convert 15 to BCD.
1
0001

5
0101BCD

Digital Codes BCD (Cont.)


Addition
Step 1: Add the two BCD numbers, using the rules
for binary addition
Step 2: If a 4-bit sum is equal to or less than 9, it
is a valid BCD number
Step 3: If a 4-bit sum is greater than 9 / if a carry
out is generated, it is an invalid BCD
result.
Add 6 (0110) to the 4-bit sum

Digital Codes BCD (Cont.)


Addition Valid number

Example:
0011
+0100
0111

(Valid BCD number)

Digital Codes BCD (Cont.)


Addition Not valid number

Example:

1001
+
0100
1101
+
0110
00010011
1

(Invalid BCD number coz >9)


(Add 6)
(Valid BCD number)

Digital Codes - ASCII

ASCII (American Standard Code for Information


Interchange) Code
Used to translate from the keyboard characters to computer
language

ASCII Codes - Table

Digital Codes - Gray


Gray Code
Only 1 bit changes
Cant be used in
arithmetic circuits
Exhibits only a single

change from one code


word to the next in
sequence
Need to know how to
convert binary to Gray
and vice versa.

Decimal

Binary

Gray
Code

0000

0000

0001

0001

0010

0011

0011

0010

0100

0110

0101

0111

0110

0101

Digital Codes Gray (Cont.)


Binary to Gray Conversion
Convert binary number 10110 to gray code.

Gray Codes

Digital Codes Gray (Cont.)


Gray to Binary Conversion
Convert gray code 10110 to binary.

Solve this..
(a) Convert binary number 11111 to gray code.
Answer : ?

(b) Convert gray code 11011 to binary.


Answer : ?

Das könnte Ihnen auch gefallen