0% found this document useful (0 votes)
8 views

02- Operation of Number Systems

The document covers the fundamentals of digital logic design, focusing on number systems, data size conversions, binary operations, and various coding systems such as BCD and Gray code. It includes detailed explanations of binary addition, multiplication, and conversion methods between different numeral systems. Additionally, it provides examples and exercises to reinforce understanding of these concepts.

Uploaded by

Alizafar Bayani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

02- Operation of Number Systems

The document covers the fundamentals of digital logic design, focusing on number systems, data size conversions, binary operations, and various coding systems such as BCD and Gray code. It includes detailed explanations of binary addition, multiplication, and conversion methods between different numeral systems. Additionally, it provides examples and exercises to reinforce understanding of these concepts.

Uploaded by

Alizafar Bayani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Digital Logic Design

Operations of Number System’s

Prepared By: Alizafar Bayani


Bachler of Computer Science at Kabul University
Master of Communication Systems at Yazd University, Iran.
Table of contents:

✓ Data Size Conversions


✓ Binary(Addition, Fraction, Multiplication)
✓ BCD and Gray Code
✓ Complement’s(9’s, 10’s, 2’s, 1’s)

2 From 38
Common Powers (1 of 2)

Base 10: Power Preface Symbol


10-12 pico p
10-9 nano n
10-6 micro 
10-3 milli m
103 kilo k
106 mega M
109 giga G
1012 tera T 3 From 38
Common Powers (2 of 2)

Base 2:
Power Memory Size Symbol Value (Byte) Value (Bits)
20 One byte 1B 1 8
210 One kilobyte 1 KB 1,024 8,192
220 One megabyte 1 MB 1,048,576 8,388,608
230 One gigabyte 1 GB 1,073,741,824 8,589,934,592
240 One terabyte 1 TB 1,099,511,627,776 8,796,093,022,208
250 One petabyte 1 PB 1,125,899,906,842,624 9,007,199,254,740,992
260 One exabyte 1 EB 1,152,921,504,606,846,976 9,223,372,036,854,775,808
270 One zettabyte 1 ZB 1,180,591,620,717,411,303,424 9,444,732,965,739,290,435,072

280 One yottabyte 1 YB 1,208,925,819,614,629,174,706,176 9,671,406,556,917,033,397,649,408

4 From 38
Data Size Conversions (1 of 2)

✓ Formula:
From Unit To Unit Conversion Factor Kilobytes (KB)×1,024=Bytes (B)
✓ Example:
Kilobytes Bytes 1 KB = 1,024 B Convert 5 KB to Bytes:
5 KB × 1,024=5,120 Bytes
Megabytes Kilobytes 1 MB = 1,024 KB
✓ Formula:
Gigabytes Megabytes 1 GB = 1,024 MB Megabytes (MB)×1,024=Kilobytes (KB)
✓ Example:
Terabytes Gigabytes 1 TB = 1,024 GB
Convert 3 MB to KB:
3MB × 1,024=3,072 KB

5 From 38
Data Size Conversions (2 of 2)

✓ Convert 85,899,345,920 bits to GigaByte.


✓ Step 3: Convert kilobytes to megabytes (MB)
✓ Step 1: Convert bits to bytes

✓ Step 4: Convert megabytes to gigabytes (GB)


✓ Step 2: Convert bytes to kilobytes (KB)

6 From 38
Example

In the lab:
▪ Double click on My Computer
▪ Right click on C:
▪ Click on Properties

7 From 38
Exercise – Free Space

✓ Determine the “free space” all drives of your laptop

Free space
Drive
Bytes GB
A:

C:
D:

E:
etc.
8 From 38
Binary Addition (1 of 2)

✓ Two 1-bit values

A B A+B
0 0 0
0 1 1
1 0 1
1 1 10

“two” 9 From 38
Binary Addition (2 of 2)

✓ Two n-bit values


o Add individual bits
o Propagate carries
1 1
10101 21
+11001 + 25
101110 46

10 From 38
Multiplication (1 of 2)

✓ Binary, Two 1-bit values


A B AB
0 0 0
0 1 0
1 0 0
1 1 1

11 From 38
Multiplication (2 of 2)

✓ Binary, two n-bit values


o As with decimal values
o Example
1110 35
 1011  105
1110 175
1110 00
0000 35
1110 3675
10011010 12 From 38
Fractions

✓ Binary to decimal
o Example

10.1011 => 1 x 2-4 = 0.0625


1 x 2-3 = 0.125
0 x 2-2 = 0.0
1 x 2-1 = 0.5
0 x 20 = 0.0
1 x 21 = 2.0
2.6875 13 From 38
Fractions
.14579
✓ Decimal to binary x 2
3.14579 0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
1.33056
14 From 38
11.001001... etc.
Exercise – Convert

Decimal Binary Octal Hexa-decimal


29.8
101.1101
3.07
C.82

15 From 38
Binary Digital Codes

✓ BCD
✓ BCD XS 3 – BCD Excess 3 code
✓ Gray Code

16 From 38
Binary Coded Decimal (BCD)

✓ Representing one decimal number at a time


Numeral BCD Representation
✓ How can we represent the ten decimal 0 0000
numbers (0-9) in binary code? 1 0001
◼ We can represent any integer by a string of 2 0010
binary digits. 3 0011
◼ For example, 749 can be represented in 4 0100
5 0101
binary as: 011101001001
6 0110
7 0111
8 1000
9 1001

17 From 38
BCD – Binary Coded Decimal

✓ BCD is a convention for mapping binary numbers to decimal numbers.


✓ When the decimal numbers are represented in BCD, each decimal digit is represented
by the equivalent BCD code.
✓ Example :BCD Representation of Decimal 6349

6 3 4 9
0110 0011 0100 1001

18 From 38
BCD Examples

Decimal Number BCD Number

10 0001 0000
121 0001 0010 0001
234 0010 0011 0100
1003 0001 0000 0000 0011
19 From 38
GRAY CODE

✓ Unweighted and is not an arithmetic code


✓ Only one bit changes from one code to the next in the sequence
✓ Gray code can be any amounts of bits.
✓ The gray code originated when digital logic circuits were built from vacuum
tubes and electromechanical relays
✓ Counters generated tremendous power demands and noise spikes when
many bits changed at once
✓ Using gray code counters, any increment or decrement changed only one bit

20 From 38
Binary-to-Gray code conversion

✓ The MSB in the Gray code is the same as corresponding MSB in the binary number.
✓ Going from left to right, add each adjacent pair of binary code bits to get the next
Gray code bit. Discard carries.
Example: convert 101102 to Gray code

1 + 0 + 1 + 1 + 0 Binary

Gray 1 1 1 0 1
21 From 38
The Gray Code

Decimal Binary Gray Code Decimal Binary Gray Code


0 0000 0000 8 1000 1100
1 0001 0001 9 1001 1101
2 0010 0011 10 1010 1111
3 0011 0010 11 1011 1110
4 0100 0110 12 1100 1010
5 0101 0111 13 1101 1011
6 0110 0101 14 1110 1001
7 0111 0100 15 1111 1000 22 From 38
Gray-to-Binary Conversion

✓ The MSB in the binary code is the same as the corresponding bit in the Gray code.
✓ Add each binary code bit generated to the Gray code bit in the next adjacent position.
Discard carries.
Example: convert the Gray code word 11011 to binary

1 1 0 1 1 Gray
+ + + +

Binary 1 0 0 1 0
23 From 38
Alphanumeric Codes

✓ Represent numbers and alphabetic characters.


o Also represent other characters such as symbols and various instructions
necessary for conveying information.
✓ The ASCII is the most common alphanumeric code.
o ASCII = American Standard Code for Information Interchange

24 From 38
ASCII

✓ ASCII has 128 characters and symbols represented by a


7-bit binary code.
o (the first 32) – control characters
o Graphics symbols (can be printed or displayed)

25 From 38
Sign Magnitude

✓ An extra bit in the most significant position is


designated as the sign bit which is to the left of an
unsigned integer. The unsigned integer is the
magnitude.

x xxx xxxx
✓ A 0 in the sign bit means positive, and a 1 means
negative
26 From 38
Sign Extension - complement

✓ For positive number, a 0 is The original number is


used to stuff the remaining 0xxxxxxx placed into the least
positions. significant portion

000000000xxxxxxx

The original number is


✓ For negative number, a 1 is 1xxxxxxx placed into the least
used to stuff the remaining significant portion
positions.
111111111xxxxxxx 27 From 38
9’s complement Examples

9 9 9 9 9 9
✓ Find the 9’s complement of


546700 and 12389
The 9’s complement of 546700 is
- 5 4 6 7 0 0

999999 - 546700= 453299 4 5 3 2 9 9

9 9 9 9 9
✓ and the 9’s complement of 12389
is 99999- 12389 = 87610. - 1 2 3 8 9

8 7 6 1 0
28 From 38
10’s complement Examples

✓ Find the 10’s complement of 1 0 0 0 0 0 0


546700 and 12389
✓ The 10’s complement of 546700 - 5 4 6 7 0 0

is:
4 5 3 3 0 0
1000000 - 546700= 453300
✓ and the 10’s complement of
12389 is: 1 0 0 0 0 0

100000 - 12389 = 87611.


✓ Notice that it is the same as 9’s
- 1 2 3 8 9

complement + 1. 8 7 6 1 1 29 From 38
2’s complement

✓ For binary numbers, r = 2, r’s


complement is the 2’s
complement. The 2’s complement
of N is 2n - N.
1 0 0 0 0 0

- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit

30 From 38
2’s complement Example

1 0 0 0 0 0 0 0
✓ The 2’s complement of 1011001
is: 0100111
- 1 0 1 1 0 0 1

0 1 0 0 1 1 1

✓ The 2’s complement of 0001111 1 0 0 0 0 0 0 0


is: 1110001
- 0 0 0 1 1 1 1

1 1 1 0 0 0 1
31 From 38
1’s complement

✓ For binary numbers, r = 2 and r -1 = 1,


✓ r-1’s complement is the l’s complement.
✓ The l’s complement of N is (2n - 1) - N.

Bit n-1 Bit n-2 ……. Bit 1 Bit 0

1 1 1 1 1

- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit

32 From 38
1’s complement

✓ Find r-1 complement for binary number N with four binary


digits.
✓ r-1 complement for binary means 2-1 complement or 1’s
complement.
✓ n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2.
✓ The l’s complement of N is (24 - 1) - N. = (1111) - N

33 From 38
1’s complement

1 1 1 1 1 1 1
✓ The complement 1’s of
1011001 is 0100110
- 1 0 1 1 0 0 1

0 1 0 0 1 1 0

1 1 1 1 1 1 1
✓ The 1’s complement of
0001111 is 1110000 - 0 0 0 1 1 1 1

1 1 1 0 0 0 0
34 From 38
34
Fast Methods for 2’s Complement

✓ Method 1:
✓ The 2’s complement of binary number is obtained by
adding 1 to the l’s complement value.
✓ Example:
✓ 1’s complement of 101100 is 010011 (invert the 0’s
and 1’s)
✓ 2’s complement of 101100 is 010011 + 1 = 010100

35 From 38
35
Fast Methods for 2’s Complement

✓ Method 2:
✓ The 2’s complement can be formed by leaving all least significant
0’s and the first 1 unchanged, and then replacing l’s by 0’s and 0’s
by l’s in all other higher significant bits.
✓ Example:
✓ The 2’s complement of 1101100 is 0010100
✓ Leave the two low-order 0’s and the first 1 unchanged, and then
replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.
36 From 38
36
Exercise

1’s complement 2’s complement

0011010 ?
? 101100110
101010010 ?
? 10010010011
37 From 38
AT THE END!

38 From 38

You might also like