Number Systems in Computer Science

umbc cmsc 104 section 01 fall 2016 n.w
1 / 30
Embed
Share

Explore the basics of binary and decimal number systems in computer science, including their structures and significance in data storage and access. Discover why base 2 and base 10 are fundamental to how information is processed in computers.

  • Computer Science
  • Number Systems
  • Binary
  • Decimal
  • Data Storage

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. UMBCCMSC 104 Section 01, Fall 2016 1

  2. Nothing. Enjoy your weekend! UMBC CMSC 104, Section 01 - Fall 2016 2

  3. I want to try something different with this class Everyone log off your PC and put away your phones/calculators/electronic devices! Break out some paper and a pen/pencil We will be done the slides quickly. I will put up some conversion problems at the end to test your understanding. We re all adults here if you need more help, you can stay. If it clicks , you can go. Don t be concerned if it doesn t click right away. Stick around. UMBC CMSC 104, Section 01 - Fall 2016 3

  4. A bit is a single binary digit (a 1 or 0). A byte is 8 bits A word is 32 bits or 4 bytes Long word = 8 bytes = 64 bits Quad word = 16 bytes = 128 bits Programming languages use these standard number of bits when organizing data storage and access. UMBC CMSC 104, Section 01 - Fall 2016 4

  5. The on and off states of the capacitors in RAM can be thought of as the values 1 and 0, respectively. Therefore, thinking about how information is stored in RAM requires knowledge of the binary (base 2) number system. Let s review the decimal (base 10) number system first. UMBC CMSC 104, Section 01 - Fall 2016 5

  6. The decimal number system is a positional number system. Example: 5 6 2 1 . 4 103 102 101 100 10-1 1 X 100 = 1 4 X 10-1 = . 4 2 X 101 = 20 6 X 102 = 600 5 X 103 = 5000 UMBC CMSC 104, Section 01 - Fall 2016 6

  7. The decimal number system is also known as base 10. The values of the positions are calculated by taking 10 to some power. Why is the base 10 for decimal numbers? Because we use 10 digits, the digits 0 through 9. UMBC CMSC 104, Section 01 - Fall 2016 7

  8. The binary number system is also known as base 2. The values of the positions are calculated by taking 2 to some power. Why is the base 2 for binary numbers? Because we use 2 digits, the digits 0 and 1. UMBC CMSC 104, Section 01 - Fall 2016 8

  9. The binary number system is also a positional numbering system. Instead of using ten digits, 0 - 9, the binary system uses only two digits, 0 and 1. Example of a binary number and the values of the positions: 1 0 0 1 1 0 1 26 25 24 23 22 21 20 ? UMBC CMSC 104, Section 01 - Fall 2016 9

  10. 1 0 0 1 1 0 1 26 25 24 23 22 21 20 20 = 1 21 = 2 22 = 4 23 = 8 1 X 20 = 1 0 X 21 = 0 1 X 22 = 4 1 X 23 = 8 0 X 24 = 0 0 X 25 = 0 1 X 26 = 64 7710 24 = 16 25 = 32 26 = 64 UMBC CMSC 104, Section 01 - Fall 2016 10

  11. Practice conversions: Binary Decimal 11101 1010101 100111 ? UMBC CMSC 104, Section 01 - Fall 2016 11

  12. Make a list of the binary place values up to the number being converted. Perform successive divisions by 2, placing the remainder of 0 or 1 in each of the positions from right to left. Continue until the quotient is zero. Example: 4210 25 24 23 22 21 20 32 16 8 4 2 1 1 0 1 0 1 0 UMBC CMSC 104, Section 01 - Fall 2016 12

  13. Practice conversions: Decimal Binary 59 82 175 UMBC CMSC 104, Section 01 - Fall 2016 13

  14. 0 1 0 1 0 0 0 0 1 0 1 0 0 1 1 1 = ? Humans can t work well with binary numbers; there are too many digits to deal with. Memory addresses and other data can be quite large. Therefore, we sometimes use the hexadecimal number system. UMBC CMSC 104, Section 01 - Fall 2016 14

  15. The hexadecimal number system is also known as base 16. The values of the positions are calculated by taking 16 to some power. Why is the base 16 for hexadecimal numbers ? Because we use 16 symbols, the digits 0 through 9 and the letters A through F. UMBC CMSC 104, Section 01 - Fall 2016 15

  16. Binary Decimal Hexadecimal 0 0 0 1 1 1 10 2 2 11 3 3 100 4 4 101 5 5 110 6 6 111 7 7 1000 8 8 1001 9 9 1010 10 A 1011 11 B 1100 12 C 1101 13 D 1110 14 E 1111 15 F UMBC CMSC 104, Section 01 - Fall 2016 16

  17. Example of a hexadecimal number and the values of the positions: 3 C 8 B 0 5 1 166 165 164 163 162 161 160 UMBC CMSC 104, Section 01 - Fall 2016 17

  18. Binary: 1 0 1 0 0 0 0 1 0 1 0 0 1 1 12 Decimal: 2064710 Hexadecimal: 50A716 Notice how the number of digits gets smaller as the base increases. UMBC CMSC 104, Section 01 - Fall 2016 18

  19. Because both Hex and Binary are based on powers of two, converting from Binary to Hex (or Hex to Binary) is simple. Binary: 1 1 1 1 0 1 0 0 1 0 1 1 1 1 0 12 Hex F 4 B D 16 UMBC CMSC 104, Section 01 - Fall 2016 19

  20. Same principals as before Try converting this hexadecimal value to decimal 3 A F 9 . B16 B X 16-1 = .69 163 162 161 160 16-1 9 X 160 = 9 F X 161 = 240 A X 162 = 2560 3 X 163 = 12288 15097.6910 UMBC CMSC 104, Section 01 - Fall 2016 20

  21. Make a list of the hex place values up to the number being converted. Perform successive divisions by 16, placing the remainder in each of the positions from right to left. Continue until the quotient is zero. Example: 34710 162 161 160 256 16 1 1 5 B UMBC CMSC 104, Section 01 - Fall 2016 21

  22. The logic weve applied goes for any arbitrary number system What would a base 7 number system look like? 5 6 2 1 . 47 4 X 7-1 = .57 73 72 71 70 7-1 1 X 70 = 1 2 X 71 = 14 6 X 72 = 294 5 X 73 = 1715 2024.5710 UMBC CMSC 104, Section 01 - Fall 2016 22

  23. UMBC CMSC 104, Section 01 - Fall 2016 23

  24. From Decimal to Binary 19 89 234 From Binary to Decimal 0001 1101 1001 0110 0111 0001 UMBC CMSC 104, Section 01 - Fall 2016 24

  25. From Decimal to Binary 19 = 0001 0011 89 = 0101 1001 234 = 1110 1010 From Binary to Decimal 0001 1101 = 29 1001 0110 = 150 0111 0001 = 113 UMBC CMSC 104, Section 01 - Fall 2016 25

  26. From Decimal to Hex 116 516 From Hex to Decimal A7 B0B UMBC CMSC 104, Section 01 - Fall 2016 26

  27. From Decimal to Hex 116 = 74 516 = 204 From Hex to Decimal A7 = 167 B0B = 2827 UMBC CMSC 104, Section 01 - Fall 2016 27

  28. 28

  29. 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1 UMBC CMSC 104, Section 01 - Fall 2016 29

  30. 163 162 161 160 4096 256 16 1 UMBC CMSC 104, Section 01 - Fall 2016 30

Related


More Related Content