chapter v number systems and arithmetic
play

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC R.M. Dansereau; v.1.0 - PowerPoint PPT Presentation

INTRO. TO COMP. ENG. CHAPTER V CHAPTER V-1 NUMBERS & ARITHMETIC CHAPTER V NUMBER SYSTEMS AND ARITHMETIC R.M. Dansereau; v.1.0 NUMBER SYSTEMS INTRO. TO COMP. ENG. NUMBER SYSTEMS CHAPTER V-2 RADIX-R REPRESENTATION NUMBERS &


  1. INTRO. TO COMP. ENG. •CHAPTER V CHAPTER V-1 NUMBERS & ARITHMETIC CHAPTER V NUMBER SYSTEMS AND ARITHMETIC R.M. Dansereau; v.1.0

  2. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS CHAPTER V-2 RADIX-R REPRESENTATION NUMBERS & ARITHMETIC • Decimal number expansion ( × ) ( × ) ( × ) ( × ) ( × ) 10 4 10 3 10 2 10 1 10 0 73625 10 7 3 6 2 5 = + + + + • Binary number representation ( × ) ( × ) ( × ) ( × ) ( × ) 2 4 2 3 2 2 2 1 2 0 10110 2 1 0 1 1 0 22 10 = + + + + = • Hexadecimal number representation ( × ) ( × ) ( × ) ( × ) ( × ) 16 4 16 3 16 2 16 1 16 0 3E4B8 16 3 14 4 11 8 = + + + + 255160 10 = R.M. Dansereau; v.1.0

  3. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -NUMBER REPRES. CHAPTER V-3 DECIMAL REPRESENTATION NUMBERS & ARITHMETIC Radix-10 Representation 73625.4385 10 10 3 10 2 10 1 10 0 – 10 2 – 10 3 – 10 4 10 5 10 4 10 1 10 5 – – ... ... 0 7 3 6 2 5 . 4 3 8 5 0 ( × ) ( × ) ( × ) ( × ) ( × ) 10 4 10 3 10 2 10 1 10 0 73625.4385 10 7 3 6 2 5 = + + + + ( × ) ( × ) ( × ) ( × ) 10 1 10 2 10 3 10 4 – – – – 4 3 8 5 + + + + R.M. Dansereau; v.1.0

  4. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -NUMBER REPRES. CHAPTER V-4 -DECIMAL REPRES. BINARY REPRESENTATION NUMBERS & ARITHMETIC Radix-2 Representation 10110.0011 2 2 5 2 4 2 3 2 2 2 1 2 0 2 1 2 2 2 3 2 4 2 5 – – – – – ... ... 0 1 0 1 1 0 . 0 0 1 1 0 MSB LSB ( × ) ( × ) ( × ) ( × ) ( × ) 2 4 2 3 2 2 2 1 2 0 10110.0011 2 1 0 1 1 0 = + + + + ( × ) ( × ) ( × ) ( × ) 2 1 2 2 2 3 2 4 – – – – 0 0 1 1 + + + + 22.1875 10 = R.M. Dansereau; v.1.0

  5. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -NUMBER REPRES. CHAPTER V-5 -DECIMAL REPRES. OCTAL REPRESENTATION NUMBERS & ARITHMETIC -BINARY REPRES. Radix-8 Representation 26516.1731 8 8 5 8 4 8 3 8 2 8 1 8 0 8 1 8 2 8 3 8 4 8 5 – – – – – ... ... 0 2 6 5 1 6 . 1 7 3 1 0 ( × ) ( × ) ( × ) ( × ) ( × ) 8 4 8 3 8 2 8 1 8 0 26516.1731 8 2 6 5 1 6 = + + + + ( × ) ( × ) ( × ) ( × ) 8 1 8 2 8 3 8 4 – – – – 1 7 3 1 + + + + 11598.24 10 = R.M. Dansereau; v.1.0

  6. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -DECIMAL REPRES. CHAPTER V-6 -BINARY REPRES. HEXADECIMAL REPRES. NUMBERS & ARITHMETIC -OCTAL REPRES. Radix-16 Representation 19AD6.F411 16 16 3 16 2 16 1 16 0 – 16 2 – 16 3 – 16 4 16 5 16 4 16 1 16 5 – – ... ... 0 1 9 A D 6 . F 4 1 1 0 ( × ) ( × ) ( × ) ( × ) ( × ) 16 4 16 3 16 2 16 1 16 0 19AD6.F411 16 1 9 A D 6 = + + + + ( × ) ( × ) ( × ) ( × ) 16 1 16 2 16 3 16 4 – – – – F 4 1 1 + + + + ≈ 105174.95 10 R.M. Dansereau; v.1.0

  7. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -BINARY REPRES. CHAPTER V-7 -OCTAL REPRES. BINARY <-> HEXADECIMAL NUMBERS & ARITHMETIC -HEXADECIMAL REPRES. BINARY -> HEXADECIMAL BINARY <-> HEXADECIMAL Group binary by 4 bits from radix point 0000 2 = 0 16 1000 2 = 8 16 Examples: 0001 2 = 1 16 1001 2 = 9 16 0010 2 = 2 16 1010 2 = 10 ( A 16 ) 0111 1011 2 = 7B 16 0011 2 = 3 16 1011 2 = 11 ( B 16 ) 7 B 0100 2 = 4 16 1100 2 = 12 ( C 16 ) 0101 2 = 5 16 1101 2 = 13 ( D 16 ) 0110 2 = 6 16 1110 2 = 14 ( E 16 ) 10 1010 0110.1100 01 2 = 2A6.C4 16 0111 2 = 7 16 1111 2 = 15 (F 16 ) 2 A 6 C 4 R.M. Dansereau; v.1.0

  8. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -BINARY REPRES. CHAPTER V-8 -OCTAL REPRES. BINARY <-> OCTAL NUMBERS & ARITHMETIC -BINARY<->HEXADECIMAL BINARY -> OCTAL BINARY <-> OCTAL Group binary bits by 3 from LSB 000 2 = 0 8 Examples: 001 2 = 1 8 010 2 = 2 8 10 100 110 2 = 246 8 011 2 = 3 8 100 2 = 4 8 2 4 6 101 2 = 5 8 110 2 = 6 8 10 101 111 011.011 11 2 = 2573.36 8 111 2 = 7 8 2 5 7 3 3 6 R.M. Dansereau; v.1.0

  9. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -OCTAL REPRES. CHAPTER V-9 -BINARY<->HEXADECIMAL BINARY -> DECIMAL NUMBERS & ARITHMETIC -BINARY<->OCTAL • Perform radix-2 expansion • Multiply each bit in the binary number by 2 to the power of its place. Then sum all of the values to get the decimal value. Examples: ( × ) ( × ) ( × ) ( × ) ( × ) 2 4 2 3 2 2 2 1 2 0 10111 2 1 0 1 1 1 23 10 = + + + + = ( × ) ( × ) ( × ) ( × ) ( × ) 2 4 2 3 2 2 2 1 2 0 10110.0011 2 1 0 1 1 0 = + + + + ( × ) ( × ) ( × ) ( × ) 2 1 2 2 2 3 2 4 – – – – 0 0 1 1 + + + + 22.1875 10 = R.M. Dansereau; v.1.0

  10. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -BINARY<->HEXADECIMAL CHAPTER V-10 -BINARY<->OCTAL DECIMAL -> BINARY NUMBERS & ARITHMETIC -BINARY->DECIMAL • Integer part: Example: Convert 41.828125 10 • Modulo division of decimal 41 mod 2 1 LSB = 20 mod 2 0 = integer by 2 to get each bit, 10 mod 2 0 = starting with LSB. 5 mod 2 1 = • Fraction part: 2 mod 2 0 = 1 mod 2 1 • Multiplication decimal MSB = fraction by 2 and collect × 0.828125 2 1.65625 MSB = × resulting integers, starting 0.65625 2 1.3125 = × 0.3125 2 0.625 = with MSB. × 0.625 2 1.25 = × 0.25 2 0.5 = × LSB 0.5 2 1.0 = Therefore 41.828125 10 101001.110101 2 = R.M. Dansereau; v.1.0

  11. NUMBER SYSTEMS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -BINARY<->HEXADECIMAL CHAPTER V-11 -BINARY->DECIMAL FLOATING POINT NUMBERS NUMBERS & ARITHMETIC -DECIMAL->BINARY • Floating point numbers can be represented with a sign bit, a fraction (often referred to as the mantissa), and an exponent. × 10 3 • Example 1: 267.426 0.267426 , where the sign is negative, – = – the fraction is 0.267426 and the exponent is . 3 × 2 6 • Example 2: 0101011.1001 0.1010111 , where the sign is = positive, the fraction is 0.1010111 , and the exponent is 0110 . • Sample IEEE Floating-Point Formats s e f 32-bit 1 8 23 64-bit s e f 1 11 52 R.M. Dansereau; v.1.0

  12. BINARY NUMBERS INTRO. TO COMP. ENG. •NUMBER SYSTEMS -DECIMAL->BINARY CHAPTER V-12 -POWERS OF 2 UNSIGNED INTEGER NUMBERS & ARITHMETIC -FLOATING POINT • The range for an -bit radix- unsigned integer is n r [ , ] n 0 r 10 1 – • Example: For a 16-bit binary unsigned integer, the range is [ , ] [ , ] 0 2 16 1 0 65535 – = which has a binary representation of 0000 0000 0000 0000 = 0 0000 0000 0000 0001 = 1 0000 0000 0000 0010 = 2 . . . 1111 1111 1111 1110 = 65534 1111 1111 1111 1111 = 65535 R.M. Dansereau; v.1.0

  13. BINARY NUMBERS INTRO. TO COMP. ENG. •NUMBER SYSTEMS •BINARY NUMBERS CHAPTER V-13 -UNSIGNED INTEGERS SIGNED INTEGERS (1) NUMBERS & ARITHMETIC • The range for an -bit radix- signed integer is n r [ , ] n 1 n 1 – – r 10 r 10 1 – – • The most-significant bit is used as a sign bit, where 0 indicates a positive integer and 1 indicates a negative integer. Example: For a 16-bit binary signed integer, the range is [ , ] [ , ] 2 16 1 2 16 1 – – 1 32768 32767 – – = – R.M. Dansereau; v.1.0

  14. BINARY NUMBERS INTRO. TO COMP. ENG. •NUMBER SYSTEMS •BINARY NUMBERS CHAPTER V-14 -UNSIGNED INTEGERS SIGNED INTEGERS (2) NUMBERS & ARITHMETIC -SIGNED INTEGERS • There are a number of different representations for signed integers, each which has its own advantage • Signed-magnitude representation: • 1010 0001 0110 1111 • Signed-1’s complement representation: • 1101 1110 1001 0000 • Signed-2’s complement representation: • 1101 1110 1001 0001 • The above examples are all the same number, 8559 10 . – R.M. Dansereau; v.1.0

  15. BINARY NUMBERS INTRO. TO COMP. ENG. •NUMBER SYSTEMS •BINARY NUMBERS CHAPTER V-15 -UNSIGNED INTEGERS SIGNED-MAGNITUDE NUMBERS & ARITHMETIC -SIGNED INTEGERS • The signed-magnitude binary integer representation is just like the unsigned representation with the addition of a sign bit . • For instance, using 8-bits, the number 6 10 can be represented as the – 7-bit magnitude of using 6 10 000 0110 and then the sign bit appended to the MSB to form 1000 0110 R.M. Dansereau; v.1.0

  16. BINARY NUMBERS INTRO. TO COMP. ENG. •BINARY NUMBERS -UNSIGNED INTEGERS CHAPTER V-16 -SIGNED INTEGERS RADIX COMPLEMENTS NUMBERS & ARITHMETIC -SIGNED-MAGNITUDE • The radix complement , or r’s complement , of an integer representation for an -digit integer is defined as n r n 10 number 10 – • The diminished radix complement , or (r - 1)’s complement , of an integer representation for an -digit integer is defined as n ( ) r n 10 1 10 number 10 – – • Example: Find the r’s and (r - 1)’s complement for 3764 10 r’s complement (r - 1)’s complement ( ) 10 5 10 5 3764 96236 1 3764 96235 – = – – = R.M. Dansereau; v.1.0

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend