james1375
Uploaded by
63 SLIDES
0 VUES
0LIKES

Lesson 2-Binary Numbers

DESCRIPTION

jbbhbhbhbhbhb jbjbjbj

1 / 63

Télécharger la présentation

Lesson 2-Binary Numbers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 208 Digital Systems & Logic Design Binary Numbers Lesson 02

  2. Main Topics – Chapter 1 1. Digital Systems 2. Binary Numbers 3. Number‐Base Conversions 4. Octal and Hexadecimal Numbers 5. Complements of Numbers 6. Signed Binary Numbers 7. Binary Codes 8. Binary Storage and Registers 9. Binary Logic

  3. Binary Numbers • Digits are 1 and 0 • 1 = true • 0 = false • MSB – most significant bit • LSB – least significant bit MSB LSB 1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 • Bit numbering: 15 0

  4. Binary Numbers Base or radix • Decimal number j a … a5a4a3a2a1a0.a1a2a3… Decimal point Power              5 4 3 2 1 0 1 2 3 10 10 10 10 10 10 10 10 10 a a a a a a a a a    5 4 3 2 1 0 1 2 3 Example: 7 10   3 10   2 10   9 10   3 2 1 0 7,329

  5. Number Systems Number System defines a set of values used to represent quantity. Name Base /Radix (r) Numbers Binary 2 0 to (2-1) = 0 , 1 Octal 8 0 to (8-1) = 0.1.2.3.4.5.6.7 Decimal 10 0 to (10-1) = 0,1,2,3,4,5,6,7,8,9 Duodecimal 12 0 to (12-1) = 0,1,2,…,9,A,B Hexadecimal 16 0 to (16-1) = 0,1,2,3,…,A,B,C,D,E,F

  6. Binary Numbers • Each digit (bit) is either 1 or 0 • Each bit represents a power of 2: 1 1 1 1 1 1 1 1 27 26 25 24 23 22 21 20 Every binary number is a sum of powers of 2

  7. Translating Binary to Decimal Weighted positional notation shows how to calculate the decimal value of each binary bit: dec = (Dn-1  2n-1) + (Dn-2  2n-2) + ... + (D1  21) + (D0  20) D = binary digit Binary 00001001 = decimal 9: (1  23) + (1  20) = 9

  8. Example 1 What is the decimal representation of each of the following unsigned binary integers? a. 00110101 1 0 1 0 1 1 1 1 1 0 1 1 1 0 1 1 27 26 25 24 23 22 21 20 b. 10010110 53 32 16 4 1 c. 11001100

  9. Example 1 What is the decimal representation of each of the following unsigned binary integers? a. 00110101 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 27 26 25 24 23 22 21 20 b. 10010110 150 4 2 16 128 c. 11001100

  10. Example 1 What is the decimal representation of each of the following unsigned binary integers? a. 00110101 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 0 27 26 25 24 23 22 21 20 b. 10010110 204 64 8 4 128 c. 11001100

  11. Binary Numbers Example: Base-2 number (11010.11)    (26.75)   2 10 2   1 2   1 2   0 2   1 2   1 2   4 3 1 0 1 2 1 2 0 2 Example: Base-5 number (4021.2)   5  0 5   2 5   1 5   2 5    3 2 1 0 1 4 5 (511.5) 10 Example: Base-8 number (127.4)8 = 1 × 82+ 2 × 81+ 7 × 80+ 4 × 8-1= (87.5)10 Example: Base-16 number  11 16  6 16   5 16    15 16   3 2 1 0 (B65F) (46,687) 16 10

  12. Binary Numbers Example: Base-2 number (110101)  32 16 4 1     (53) 2 10 Special Powers of 2  210 (1024) is Kilo, denoted "K"  220(1,048,576) is Mega, denoted "M"  230(1,073, 741,824)is Giga, denoted "G" Powers of two Table 1.1

  13. Arithmetic operation Arithmetic operations with numbers in base r follow the same rules as decimal numbers.

  14. Translating Unsigned Decimal to Binary • Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value: 37 = 100101

  15. Example 2 What is the minimum number of binary bits needed to represent each of the following signed decimal integers? a. 4095 b. 65534 c. 42319 2 1023 1 1 2 4095 2 63 1 1 1 1 1 1 1 1 1 1 2 2047 2 31 2 15 2 511 2 7 2 255 2 3 2 127 2 1

  16. Example 2 What is the minimum number of binary bits needed to represent each of the following signed decimal integers? a. 4095 b. 65534 c. 42319 2 16383 1 1 1 1 0 1 1 2 65534 2 1023 2 15 1 1 1 1 1 1 1 1 1 2 32767 2 511 2 7 2 255 2 3 2 8191 2 127 2 1 63 2 4095 2 2 2047 2 31

  17. Example 2 What is the minimum number of binary bits needed to represent each of the following signed decimal integers? a. 4095 b. 65534 c. 42319 2 10579 1 1 1 0 1 0 0 2 42319 2 661 2 20 1 1 0 1 0 1 0 1 0 1 2 21159 2 330 2 10 2 165 2 5 2 5089 2 127 2 2 82 2 2644 2 2 1 2 1322 2 41

  18. Binary Addition • Starting with the LSB, add each pair of digits, include the carry if present. carry: 1 0 0 0 0 0 1 0 0 (4) + 0 0 0 0 0 1 1 1 (7) 0 0 0 0 1 0 1 1 (11) bit position: 7 6 5 4 3 2 1 0

  19. Example 3 What is the sum of each pair of binary integers? a. 10101111 + 11011011 b. 10010111 + 11111111 c. 01110101 + 10101100

  20. Example 3 What is the sum of each pair of binary integers? 1 0 1 0 1 1 1 1 a. 10101111 + 11011011 1 1 0 1 1 0 1 1 b. 10010111 + 11111111 1 0 0 0 1 0 1 0 1 c. 01110101 + 10101100

  21. Example 3 What is the sum of each pair of binary integers? 1 1 1 1 1 1 1 1 a. 10101111 + 11011011 1 0 0 1 0 1 1 1 b. 10010111 + 11111111 1 0 0 1 0 1 1 0 1 c. 01110101 + 10101100

  22. Example 3 What is the sum of each pair of binary integers? 1 0 1 0 1 1 0 0 a. 10101111 + 11011011 0 1 1 1 1 1 0 0 b. 10010111 + 11111111 0 0 1 0 0 0 0 1 1 c. 01110101 + 10101100

  23. Hexadecimal Integers Binary values are represented in hexadecimal.

  24. Translating Binary to Hexadecimal • Each hexadecimal digit corresponds to 4 binary bits. • Example: Translate the binary integer 000101101010011110010100 to hexadecimal:

  25. Example 4 What is the hexadecimal representation of each of the following binary numbers? a. 0011 0101 1101 1010 b. 1100 1110 1010 0011 c. 1111 1110 1101 1011 0011 3 3 0101 5 5 1101 D D 1010 A A

  26. Example 4 What is the hexadecimal representation of each of the following binary numbers? a. 0011 0101 1101 1010 b. 1100 1110 1010 0011 c. 1111 1110 1101 1011 1100 C C 1110 E E 1010 A A 0011 3 3

  27. Example 4 What is the hexadecimal representation of each of the following binary numbers? a. 0011 0101 1101 1010 b. 1100 1110 1010 0011 c. 1111 1110 1101 1011 1111 F F 1110 E E 1101 D D 1011 B B

  28. Example 5 What is the binary representation of the following hexadecimal numbers? a. 0126F9D4 0126F9D4 b. 6ACDFA95 c. F69BDC2A 0 0 1 1 2 2 6 6 F F 9 9 D D 4 4 0000 0000 0001 0001 0010 0010 0110 0110 1111 1111 1101 1101 0100 0100 1001

  29. Example 5 What is the binary representation of the following hexadecimal numbers? a. 0126F9D4 b. 6ACDFA95 6ACDFA95 c. F69BDC2A 6 6 A A C C D D F F A A 9 9 5 5 0110 0110 1010 1010 1100 1100 1101 1101 1111 1111 1001 1001 0101 0101 1010

  30. Example 5 What is the binary representation of the following hexadecimal numbers? a. 0126F9D4 b. 6ACDFA95 c. F69BDC2A F69BDC2A F F 6 6 9 9 B B D D C C 2 2 A A 1111 1111 0110 0110 1001 1001 1011 1011 1101 1101 0010 0010 1010 1010 1100

  31. Numbers with Different Bases

  32. Converting Hexadecimal to Decimal • Multiply each digit by its corresponding power of 16: dec = (D3 163) + (D2 162) + (D1 161) + (D0 160) • Hex 1234 equals (1  163) + (2  162) + (3  161) + (4  160), or decimal 4,660. • Hex 3BA4 equals (3  163) + (11 * 162) + (10  161) + (4  160), or decimal 15,268.

  33. Powers of 16 Used when calculating hexadecimal values up to 8 digits long:

  34. Example 6 What is the unsigned decimal representation of each of the following hexadecimal integers? a. 3A b. 1BF 16 163 3 4096 16 162 2 256 16 161 1 16 3 3 16 160 0 1 A A c. 1001 A 3*16 = 48 58

  35. Example 6 What is the unsigned decimal representation of each of the following hexadecimal integers? a. 3A b. 1BF 16 163 3 4096 16 162 2 256 1 16 161 1 16 B 16 160 0 1 F c. 1001 F 1*256 = 256 11*16 = 176 447

  36. Example 6 What is the unsigned decimal representation of each of the following hexadecimal integers? a. 3A b. 1BF 16 163 3 4096 1 16 162 2 256 0 16 161 1 16 0 16 160 0 1 1 c. 1001 1 4096 4 097

  37. Converting Decimal to Hexadecimal decimal 422 = 1A6 hexadecimal

  38. Example 7 What is the unsigned hexadecimal representation of each of the following decimal integers? a. 62 Division Division 62/16 3/16 Quotient Quotient 3 Remainder Remainder 14 = E b. 433 c. 298 0 3 6210= 3E16

  39. Example 7 What is the unsigned hexadecimal representation of each of the following decimal integers? a. 62 Division Division 433/16 27/16 Quotient Quotient 27 Remainder Remainder 1 b. 433 c. 298 1 11 = B 1 1/16 0 43310= 1B116

  40. Example 7 What is the unsigned hexadecimal representation of each of the following decimal integers? a. 62 Division Division 298/16 18/16 Quotient Quotient 18 Remainder Remainder 10 = A b. 433 c. 298 1 2 1 1/16 0 29810= 12A16

  41. Hexadecimal Addition • Divide the sum of two digits by the number base (16). The quotient becomes the carry value, and the remainder is the sum digit. 1 1 36 42 78 28 45 6D 28 58 80 6A 4B B5 21 / 16 = 1, rem 5 Important skill: Programmers frequently add and subtract the addresses of variables and instructions.

  42. Example 8 What is the sum of each pair of hexadecimal integers? a. a. 6B4 + 3FE 6B4 + 3FE 1 1 b. A49 + 6BD 3 3 F F E E c. 7C4 + 3BE 6 B 4 A B 2 d. B69 + 7AD

  43. Example 8 What is the sum of each pair of hexadecimal integers? a. 6B4 + 3FE 1 1 b. b. A49 + 6BD A49 + 6BD 6 6 B B D D c. 7C4 + 3BE A 4 9 1 0 6 1 d. B69 + 7AD

  44. Example 8 What is the sum of each pair of hexadecimal integers? a. 6B4 + 3FE 1 1 b. A49 + 6BD 3 3 B B E E c. c. 7C4 + 3BE 7C4 + 3BE 7 C 4 B 8 2 d. B69 + 7AD

  45. Example 8 What is the sum of each pair of hexadecimal integers? a. 6B4 + 3FE 1 1 b. A49 + 6BD 7 7 A A D D c. 7C4 + 3BE B 6 9 3 1 6 1 d. d. B69 + 7AD B69 + 7AD

  46. Conversion between Unsigned (Decimal, Binary & Hexadecimal) (b0b1b2b3)=H0(b0b1b2b3)=H1… Binary (1,0) Hexadecimal (0,1-9,A,B,C,D,E,F) H0=(b0b1b2b3) H1=(b0b1b2b3) … Decimal (0,1,2 – 9)

  47. Convert from fraction decimal to binary • Convert (0.6875)10to binary.

  48. Convert from fraction decimal to binary • Convert (0.513)10to octal?

  49. Assignment I

  50. Problem 1 What is the exact number of bytes in a system that contains a. 16 K bytes b. 32 M bytes c. 2 G bytes.

More Related