Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)

Similar presentations


Presentation on theme: "Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)"— Presentation transcript:

1

2 Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)

3 Number System n Binary (0,1) n Octal (0,1,3,4,5,6,7) n Decimal (0,1,3,4,5,6,7,8,9) n Hexadecimal (0,1,3,4,5,6,7,8,9,A,B,C,D,E,F)

4 2.3 Table: shows a summary of the four positional number systems discussed in this chapter. Summary of the four positional systems

5 2.4 Table 2.2 shows how the number 0 to 15 is represented in different systems.

6 Binary Numbering Scale Base 2 Number Base 10 Equivalent Power Positional Value 00002020 1 00112121 2 01022 4 01132323 8 10042424 16 10152525 32 11062626 64 11172727 128

7 Converting to Decimal Hexadecimal Decimal Octal Binary

8 7 What is the decimal equivalent of the binary number 1101110? 1 x 2 6 = 1 x 64 = 64 + 1 x 2 5 = 1 x 32 = 32 + 0 x 2 4 = 0 x 16 = 0 + 1 x 2 3 = 1 x 8 = 8 + 1 x 2 2 = 1 x 4 = 4 + 1 x 2 1 = 1 x 2 = 2 + 0 x 2º = 0 x 1 = 0 = 110 in base 10 13 Converting Binary to Decimal

9 8 What is the decimal equivalent of the octal number 642? 6 x 8 2 = 6 x 64 = 384 + 4 x 8 1 = 4 x 8 = 32 + 2 x 8º = 2 x 1 = 2 = 418 in base 10 11 Converting Octal to Decimal

10 Example 724 8 => 4 x 8 0 = 4 2 x 8 1 = 16 7 x 8 2 = 448 468 10

11 Converting Decimal to other bases Hexadecimal Decimal Octal Binary

12 The following shows how to convert 35 in decimal to binary. We start with the number in decimal, we move to the left while continuously finding the quotients and the remainder of division by 2. The result is 35 = (100011) 2. Converting Decimal to Binary

13 The following shows how to convert 126 in decimal to its equivalent in the octal system. We move to the right while continuously finding the quotients and the remainder of division by 8. The result is 126 = (176) 8. Converting Decimal to Octal

14 The following shows how we convert 126 in decimal to its equivalent in the hexadecimal system. We move to the right while continuously finding the quotients and the remainder of division by 16. The result is 126 = (7E) 16 Converting Decimal to Hexadecimal

15 Octal to Binary n Technique u Convert each octal digit to a 3-bit equivalent binary representation

16 Example 705 8 = ? 2 7 0 5 111 000 101 705 8 = 111000101 2

17 Hexadecimal to Binary n Technique u Convert each hexadecimal digit to a 4-bit equivalent binary representation

18 Example 10AF 16 = ? 2 1 0 A F 0001 0000 1010 1111 10AF 16 = 0001000010101111 2

19 The Power of 2 n2n2n 02 0 =1 12 1 =2 22 2 =4 32 3 =8 42 4 =16 52 5 =32 62 6 =64 72 7 =128 n2n2n 82 8 =256 92 9 =512 102 10 =1024 112 11 =2048 122 12 =4096 202 20 =1M 302 30 =1G 402 40 =1T Mega Giga Tera Kilo

20 Binary Addition (1 of 2) n Two 1-bit values pp. 36-38 ABA + B 000 011 101 1110 “two”

21 20 Binary Addition (2 of 2) n Two n-bit values u Add individual bits u Propagate carries u E.g., 10101 21 + 11001 + 25 101110 46 11

22 Remember borrowing? Apply that concept here: 1 2 2 0 2 1 0 1 0 1 1 1 - 1 1 1 0 1 1 0 0 1 1 1 0 0 15 Subtracting Binary Numbers

23 22 Multiplication (2 of 3) n Binary, two 1-bit values AB A  B 000 010 100 111

24 Multiplication Example Multiplicand 1000 ten Multiplier x 1001 ten --------------- 1000 0000 1000 ---------------- Product 1001000 ten In every step multiplicand is shifted next bit of multiplier is examined (also a shifting step) if this bit is 1, shifted multiplicand is added to the product

25 Division 1001 ten Quotient Divisor 1000 ten | 1001010 ten Dividend -1000 10 101 1010 -1000 10 ten Remainder At every step, shift divisor right and compare it with current dividend if divisor is larger, shift 0 as the next bit of the quotient if divisor is smaller, subtract to get new dividend and shift 1 as the next bit of the quotient

26 1.5Complements n There are two types of complements for each base-r system: the radix complement and diminished radix complement. n Diminished Radix Complement - (r-1)’s Complement u Given a number N in base r having n digits, the (r–1)’s complement of N is defined as: (r n –1) – N n Example for 6-digit decimal numbers: u 9’s complement is (r n – 1)–N = (10 6 –1)–N = 999999–N u 9’s complement of 546700 is 999999–546700 = 453299 n Example for 7-digit binary numbers: u 1’s complement is (r n – 1) – N = (2 7 –1)–N = 1111111–N u 1’s complement of 1011000 is 1111111–1011000 = 0100111 n Observation: u Subtraction from (r n – 1) will never require a borrow u Diminished radix complement can be computed digit-by-digit u For binary: 1 – 0 = 1 and 1 – 1 = 0

27 Complements n1n1’s Complement (Diminished Radix Complement) uAuAll ‘0’s become ‘1’s uAuAll ‘1’s become ‘0’s Example (10110000) 2  (01001111) 2 If you add a number and its 1’s complement … 1 0 1 1 0 0 0 0 + 0 1 0 0 1 1 1 1 1 1 1 1

28 Complements n Radix Complement n Example: Base-10 n Example: Base-2 The r's complement of an n-digit number N in base r is defined as r n – N for N ≠ 0 and as 0 for N = 0. Comparing with the (r  1) 's complement, we note that the r's complement is obtained by adding 1 to the (r  1) 's complement, since r n – N = [(r n  1) – N] + 1. The 10's complement of 012398 is 987602 The 10's complement of 246700 is 753300 The 2's complement of 1101100 is 0010100 The 2's complement of 0110111 is 1001001

29 Complements n2n2’s Complement (Radix Complement) uTuTake 1’s complement then add 1 uTuToggle all bits to the left of the first ‘1’ from the right Example: Number: 1’s Comp.: 0 1 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1 + 1 OR

30 Complements n Subtraction with Complements u The subtraction of two n-digit unsigned numbers M – N in base r can be done as follows:

31 Complements n Example 1.5 u Using 10's complement, subtract 72532 – 3250. n Example 1.6 u Using 10's complement, subtract 3250 – 72532. There is no end carry. Therefore, the answer is – (10's complement of 30718) =  69282.

32 Complements n Example 1.7 u Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a) X – Y ; and (b) Y  X, by using 2's complement. There is no end carry. Therefore, the answer is Y – X =  (2's complement of 1101111) =  0010001.

33 Complements n Subtraction of unsigned numbers can also be done by means of the (r  1)'s complement. Remember that the (r  1) 's complement is one less then the r's complement. n Example 1.8 u Repeat Example 1.7, but this time using 1's complement. There is no end carry, Therefore, the answer is Y – X =  (1's complement of 1101110) =  0010001.


Download ppt "Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)"

Similar presentations


Ads by Google