1 / 25

Introduction to Computers and Programming (CSC103) – Lecture 1b

Introduction to Computers and Programming (CSC103) – Lecture 1b. Dr. Muhammad Kamran Email: m.kamran.nuces@gmail.com Comsats Institute of Information Technology [ www. ciitwah .edu.pk ]. Text Book Introduction to Computer Science, 2 nd Edition ITL Education Solutions Limited

brody-ayers
Download Presentation

Introduction to Computers and Programming (CSC103) – Lecture 1b

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. Introduction to Computers and Programming(CSC103) – Lecture 1b Dr. Muhammad Kamran Email: m.kamran.nuces@gmail.com Comsats Institute of Information Technology [www.ciitwah.edu.pk]

  2. Text Book Introduction to Computer Science, 2nd Edition ITL Education Solutions Limited Published by Pearson

  3. Topics to be Covered • Number Systems

  4. Number Systems • Four common number systems • Decimal – 10 Digits • Binary – 2 Digits • Octal – 8 Digits • Hexadecimal – 16 Digits • ‘Base’ ,also called ‘Radix’, represents the total number of digits of a system • We use a subscript to indicate the ‘base’ or the ‘radix’. For example, • (56)10 , (00110)2 , (253)8 , (AF14)16 Humans mostly use this

  5. Some Key Points to Remember We can convert numbers from any number system to any other number system Octa Binary Hexadecimal Octa Decimal Hexadecimal Decimal Binary OR Decimal Binary Hexadecimal Octa Decimal Binary OR Octa Hexadecimal Easiest conversion is Octa, Binary, Hexadecimal intoDecimal

  6. Decimal Number System • Comprises of ten digits • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • Lowest 0……highest 9, one less than the base of 10 • Examples are 667, 20, 2, -56 etc Remember!! Every position represents a power of the base = 4764510 + + + +

  7. Binary Number System • Comprises of only two digits • 0 and 1 • Lowest – 0, highest - 1, one less than the base 2 • Computers use binary system internally • Not efficient for representation of fractions (available fractions include ½, ¼, 1/8, 1/16…) Remember!! Every position represents a power of the base = 2210 + + + +

  8. Octal Number System • Comprises of eight digits • 0, 1, 2, 3, 4, 5, 6, 7 • Lowest - 0, Highest – 7 Remember!! Every position represents a power of the base + + + + = 596910

  9. Hexadecimal Number System • Comprises of 16 digits • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • Lowest – 0, highest – F which has a value equivalent to decimal 15 (one less than the base of 16) • It is used in low-level software and assembly language development Remember!! Every position represents a power of the base = 694510 + + +

  10. Different Conversions Now we are left with Binary, Octa and Hexadecimal conversions Binary, Octa, Hexadecimal into Decimal (we did these on slides 7,8,9) Decimal into Binary, Octa, Hexadecimal ( we will do in next lecture) Coming up in next few slides Good News Octa into Hexadecimal and vice versa (last topic for today) We have a shortcut method for Binary to Octa, Hexadecimal and vice versa conversions

  11. Binary Representation of Hexadecimal Numbers

  12. Binary Representation of Octal Numbers

  13. Conversion of Binary to Octa & Hex Lets prove it by converting all 3 into decimal !! Recall conversion method from slides 7,8,9

  14. Conversion of Octal and Hex to Binary

  15. Conversion of Hex to Octa and Vice Versa • Follow these two rules; • Convert the number into Decimal ( as we did in slides 7,8,9) • Then convert the obtained Decimal number into the other number system Hexadecimal Number Octa Number Decimal Number

  16. Decimal to Binary, Octa, Hexadecimal • Write down the base • Start dividing the decimal number by the ‘base’ • Keep recording remainders until no more division is possible • The remainders, arranged in reverse order, form the answer Lets see One example of each in next 3 slides

  17. 1. Decimal to Binary Conversion • Conversion of 4610 into Binary Base = 2 is Divisor Decimal No. is dividend 4610 = 1011102 LSB MSB

  18. 2. Decimal to Octa Conversion • Conversion of 453210 into Octa Base = 8 is Divisor Decimal No. is dividend 453210 = 106648 LSB MSB

  19. 3. Decimal to Hexadecimal Conversion • Conversion of 5047610 into Hexadecimal Base = 16 is Divisor Decimal No. is dividend 5047610 = C52C16 LSB MSB

  20. Hexadecimal to Octa and Reverse • Two Possible Ways of doing it Hexadecimal Hexadecimal Decimal Binary Octa Octa

  21. Now lets do some Binary Arithmetic Binary Addition Binary Subtraction (Borrow Method & Complement’s Method)

  22. Binary Addition • Addition table for binary digits • 0 0 1 1 • + 0 + 1 + 0 + 1 • 0 1 1 10 • sum bit • carry bit

  23. Multi-bit Binary Addition • When adding binary numbers if a carry is generated, it is carried one position to the left, just as in decimal arithmetic • Example 11 1 1 • X 173 1 0 1 0 1 1 0 1 • + Y 44 0 0 1 0 1 1 0 0 • 217 1 1 0 1 1 0 0 1

  24. Binary Subtraction • Subtraction table for binary digits • 0 0 1 1 • - 0 - 1 - 0 - 1 • 0 1 1 0 • with borrow from the next column

  25. Multi-bit Binary Subtraction • We will subtract using binary equivalents and prove the following; 2110 – 1410 = 710 Borrow 2110 1410 - 24 + 23 + 22 + 21 + 20 = 710

More Related