1 / 53

Week-3 Introduction to Number Systems

Week-3 Introduction to Number Systems. Number systems and their conversions Decimal, Binary, Octal, Hexadecimal Arithmetic operations Binary Addition Binary Subtraction Binary Multiplications Binary Division Signed and Magnitude numbers Complement numbers Binary Coded decimal numbers.

abuck
Download Presentation

Week-3 Introduction to Number Systems

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. Week-3Introduction to Number Systems • Number systems and their conversions • Decimal, Binary, Octal, Hexadecimal • Arithmetic operations • Binary Addition • Binary Subtraction • Binary Multiplications • Binary Division • Signed and Magnitude numbers Complement numbers • Binary Coded decimal numbers

  2. Common Number Systems

  3. Conversion Among Bases • The possibilities: Decimal Octal Binary Hexadecimal pp. 40-46

  4. Binary to Decimal Decimal Octal Binary Hexadecimal

  5. Binary to Decimal • Technique • Multiply each bit by 2n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results

  6. Example Bit “0” 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310

  7. Octal to Decimal Decimal Octal Binary Hexadecimal

  8. Octal to Decimal • Technique • Multiply each bit by 8n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results

  9. Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810

  10. Hexadecimal to Decimal Decimal Octal Binary Hexadecimal

  11. Hexadecimal to Decimal • Technique • Multiply each bit by 16n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results

  12. Example ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810

  13. Decimal to Binary Decimal Octal Binary Hexadecimal

  14. Decimal to Binary • Technique • Divide by two, keep track of the remainder • First remainder is bit 0 (LSB, least-significant bit) • Second remainder is bit 1 • Etc.

  15. 2 125 62 1 2 31 0 2 15 1 2 3 1 2 7 1 2 0 1 2 1 1 Example 12510 = ?2 12510 = 11111012

  16. Decimal to Octal Decimal Octal Binary Hexadecimal

  17. Decimal to Octal • Technique • Divide by 8 • Keep track of the remainder

  18. 8 19 2 8 2 3 8 0 2 Example 123410 = ?8 8 1234 154 2 123410 = 23228

  19. Decimal to Hexadecimal • Technique • Divide by 16 • Keep track of the remainder

  20. 16 1234 77 2 16 4 13 = D 16 0 4 Example 123410 = ?16 123410 = 4D216

  21. Octal to Binary Decimal Octal Binary Hexadecimal

  22. Octal to Binary • Technique • Convert each octal digit to a 3-bit equivalent binary representation

  23. 7 0 5 111 000 101 Example 7058 = ?2 7058 = 1110001012

  24. Hexadecimal to Binary Decimal Octal Binary Hexadecimal

  25. Hexadecimal to Binary • Technique • Convert each hexadecimal digit to a 4-bit equivalent binary representation

  26. 1 0 A F 0001 0000 1010 1111 Example 10AF16 = ?2 10AF16 = 00010000101011112

  27. Octal to Hexadecimal Decimal Octal Binary Hexadecimal

  28. Octal to Hexadecimal • Technique • Use binary as an intermediary

  29. 1 0 7 6 • 001 000 111 110 2 3 E Example 10768 = ?16 10768 = 23E16

  30. Hexadecimal to Octal Decimal Octal Binary Hexadecimal

  31. Hexadecimal to Octal • Technique • Use binary as an intermediary

  32. 1 F 0 C • 0001 1111 0000 1100 1 7 4 1 4 Example 1F0C16 = ?8 1F0C16 = 174148

  33. Don’t use a calculator! Exercise – Convert ... Skip answer Answer

  34. Exercise – Convert … Answer

  35. Common Powers (1 of 2) • Base 10

  36. Common Powers (2 of 2) • Base 2 • What is the value of “k”, “M”, and “G”? • In computing, particularly w.r.t. memory, the base-2 interpretation generally applies

  37. Binary Addition (1 of 2) • Two 1-bit values “two” pp. 36-38

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

  39. Binary Subtraction • Two numbers can be subtracted by subtracting each pair of digits together with borrowing, where needed. Binary Arithmetic Operations

  40. Binary Arithmetic Operations (5/6) • MULTIPLICATION • To multiply two numbers, take each digit of the multiplier and multiply it with the multiplicand. This produces a number of partial products which are then added. Binary Arithmetic Operations

  41. Binary Arithmetic Operations (6/6) • Digit multiplication table: • DIVISION – can you figure out how this is done? • Exercise: Think of the division technique (shift & subtract) used for decimal numbers and apply it to binary numbers. Binary Arithmetic Operations

  42. Multiplication (2 of 3) • Binary, two 1-bit values

  43. Multiplication (3 of 3) • Binary, two n-bit values • As with decimal values • E.g., 1110 x 1011 1110 1110 0000 111010011010

  44. Negative Numbers: Sign-and-Magnitude (1/4) • Negative numbers are usually written by writing a minus sign in front. • Example: - (12)10 , - (1100)2 • In sign-and-magnitude representation, this sign is usually represented by a bit: 0 for + 1 for - Negative Numbers: Sign-and-Magnitude

  45. magnitude sign Negative Numbers:Sign-and-Magnitude (2/4) • Example: an 8-bit number can have 1-bit sign and 7-bit magnitude. Negative Numbers:Sign-and-Magnitude

  46. 1s and 2s Complement • Two other ways of representing signed numbers for binary numbers are: • 1s-complement • 2s-complement • They are preferred over the simple sign-and-magnitude representation. 1s and 2s Complement

  47. 1s Complement (1/3) • Given a number x which can be expressed as an n-bit binary number, its negative value can be obtained in 1s-complement representation using: - x = 2n - x - 1 Example: With an 8-bit number 00001100, its negative value, expressed in 1s complement, is obtained as follows: -(00001100)2 = - (12)10 = (28 - 12 - 1)10 = (243)10 = (11110011)1s 1s Complement

  48. 1s Complement (2/3) • Essential technique: invert all the bits. Examples: 1s complement of (00000001)1s = (11111110)1s 1s complement of (01111111)1s = (10000000)1s • Largest Positive Number: 0 1111111 +(127)10 • Largest Negative Number: 1 0000000 -(127)10 • Zeroes: 0 0000000 1 1111111 • Range: -(127)10 to +(127)10 • The most significant bit still represents the sign: 0 = +ve; 1 = -ve. 1s Complement

  49. 1s Complement (3/3) • Examples (assuming 8-bit binary numbers): (14)10 = (00001110)2 = (00001110)1s -(14)10 = -(00001110)2 = (11110001)1s -(80)10 = -( ? )2 = ( ? )1s 1s Complement

  50. 2s Complement (1/4) • Given a number x which can be expressed as an n-bit binary number, its negative number can be obtained in 2s-complement representation using: - x = 2n - x Example: With an 8-bit number 00001100, its negative value in 2s complement is thus: -(00001100)2 = - (12)10 = (28 - 12)10 = (244)10 = (11110100)2s 2s Complement

More Related