1 / 10

Number systems and codes

Number systems and codes. Number systems Ordered set of symbols or digits, with defined relations for +    Radix (base) r Total # of symbols allowed in system Decimal: 10 digits {0…9}; radix = 10 Binary: 2 digits {0, 1}; radix = 2. Number systems and codes. Positional notation

sgrogan
Télécharger la présentation

Number systems and codes

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. Number systems and codes • Number systems • Ordered set of symbols or digits, with defined relations for +   • Radix (base) r • Total # of symbols allowed in system Decimal: 10 digits {0…9}; radix = 10 Binary: 2 digits {0, 1}; radix = 2

  2. Number systems and codes • Positional notation • N = (an-1 an-2 --- a0 . a-1 --- a-m) • Algebraic value of N = ? • N1 = (1357.46)10 • N1 evaluated as ?

  3. Number systems and codes • N = a polynomial of radix r • For radix r, digit set is = {0, --- ?} • Hexadecimal r = 16 • Digit set = {0, --- ?} • Why has arithmetic evolved around radix 10? • Which radix do you think is the “most efficient”?

  4. 3500 BC, Egyptians, nonpositional 2500 BC, Sumerians, positional, base 60 Today:

  5. Numeric conversions binary to octal: 10111011001 --> 10 111 011 001 --> 2731 (substitution) binary to hex: 10111011001 --> 101 1101 1001 --> 5D9 (substitution) binary to decimal: 10111011001 --> 1 (1024) + 0 (512) + 1 (256) + 1 (128) + 1 (64) + 0 (32) + 1 (16) + 1 (8) + 0 (4) + 0 (2) + 1 (1) = 1497 (summation) hex to binary: 5D9 --> 0101 1101 1001 --> 10111011001 (substitution) hex to octal: 5D9 --> 0101 1101 1001 --> 010 111 011 001 --> 2731 (substitution) hex to decimal: 5D9 --> 5 (256) + 13 (16) + 9 (1) = 1497 (summation) octal to binary: 2731 --> 010 111 011 001 --> 10111011001 (substitution) octal to hex: 2731 --> 010 111 011 001 --> 0101 1101 1001 -> 5D9 (substitution) octal to decimal: 2731 --> 2 (512) + 7 (64) + 3 (8) + 1 (1) = 1497 (summation)

  6. Base conversions (10111)2 = (?)10 20 + 21 + 22 + 24 = 23 (274)8 = (?)10 (A)rS = (?)rD

  7. Base conversions • If source radix rS < destination radix rD then • Every digit in the source number system is also a digit in the destination number system: simply evaluate polynomial in destination number system • If source radix rS > destination radix rD (97)10 = ( ? )2 N = dn-1rSn-1 + …+d0rS0 = yp-1rDp-1 + …+y0rD0 • Q: How do we find the yp-1…y0 coefficients?

  8. Base conversions } Q1 N = (yp-1rDp-2 + …+ y1)•rD + y0  N modulo rD = y0 Q1 modulo rD = y1 Q2 modulo rD = y2 ……………………… When do we stop?

  9. Base conversions Q = N; i = 0; While (Q  0) do digit [ i ] = Q mod rD Q = Q/rD End-while Division is expensive. Question: is there a way to avoid division (replace it with +, ,  and possibly some table lookups?

  10. Converting fractions f = d-1rS-1 + d-2rS-2 + … = y-1rD-1 + y-2rD-2 + … f•rD = y-1 + y-2rD-1 Integer fractional  f•rD = y-1n = floor f1•rD = y-2 .................. When do we stop? } }

More Related