Presentation is loading. Please wait.

Presentation is loading. Please wait.

DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.

Similar presentations


Presentation on theme: "DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck."— Presentation transcript:

1 DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck

2 Number Systems A set of symbols representing digits, S A string of symbols represents a value Value may be computed from the position of digits in a string (positional number system) Example: Decimal number system –base 10 or radix 10 –(724.6) 10 =7x100 + 2x10 + 4x1 + 6x1/10

3 examples Decimal: r = 10, S = {0, 1, 2,..., 9} Binary: r = 2, S = {0,1} Octal: r = 8, S = {0,1,2,3,4,5,6,7} Hexadec: r = 16, S = {0,..., 9, A,B,C,D,E,F} Conversion from one base to another: -By successive division or multiplications by the radix.

4 Positional number system Base r A number is a string Significance of a digit in a string is indicated by its position

5 Example for binary numbers A binary number is a weighted number. The structure is 2 n-1  2 3 2 2 2 1 2 0. 2 -1 2 -2 2 -3  2 -n where n is the number of bits from the binary point. Ex: conversion of the binary number 1 1 0 1 0. 0 1 1 –Weight 2 4 2 3 2 2 2 1 2 0. 2 -1 2 -2 2 -3 –Binary 1 1 0 1 0. 0 1 1 1 1 0 1 0. 0 1 1 = 2 4 + 2 3 + 2 1 + 2 -2 + 2 -3 = 16 + 8 + 2 + 0.25 + 0.125 = 26.375

6 2-to-10 and 10-to-2 Converting a binary number to a decimal number is easy : there is a radix point here What about the way back?

7 Addition and subtraction of binary numbers Same as in school: borrow from preceding neighbor By example: 1 1 1 1 0 0 1 1 1 1 1 0 0 1901 0 1 1 1 1 1 02291 1 1 0 0 1 0 1 1411 0 0 0 1 1 0 1-460 0 1 0 1 1 1 0 331 10 1 0 0 1 0 1 11831 0 1 1 0 1 1 1

8 Multiplication/division Examples –Multiplication: 7 x 5 = 35 111 x 101 = 111 + 000 + 11100 = 100011 = 35 –Division: 12 / 4 = 3 1100 / 100 = 11

9 Negative numbers Signed magnitude form 1- complement 2-complement

10 Signed magnitude representation The most significant bit indicates the sign –01010101 = +85 –11010101 = - 85 Problem is the adding/subtracting of numbers

11 1-complement representation Binary complement for negative numbers 17 = 0001000111101110 = -17 119 = 0111011110001000 = -119 sign

12 2-complement representation Positive numbers +A Negative numbers -A where

13 4-bit numbers 00 000-81 000 10 001-11 111 20 010-21 110 30 011-31 101 40 100-41 100 50 101-51 011 60 110-61 010 70 111-71 001

14 remarks Adding/subtracting – ignoring any carries beyond the MSB MSB = most significant bit (largest weight) – correct as long as range not exceeded +30011+40100 +40100-71001 +70111-31101

15 implementation Note: we represent a negative number –A as Example: 99 = 01100011 -99 = 10011100 + 1 = 10011101 Example: 98 = 01100010 -98 = 10011101 + 1 = 10011110

16 Overflow detection MSB different No problem –Reason: always within range Example:-31101+30011 +60110-61010 +30011-31101 MSB the sameMSB addition different Example:-31101+50101 -61010+60110 -90111= +7+111011 =-5

17 In other words Calculations are done modulo 2 r+1 Let a and b be positive numbers; 0  a,b < 2 r ; - a = 2 r+1 – a mod 2 r+1 + a + b + a + b = c < 2 r no problem ( overflow detected by sign comparison) - a - b - a - b = 2 r+1 – a + 2 r+1 – b = 2 r+1 – (a + b) + 2 r+1 = 2 r+1 – (a + b) modulo 2 r+1 no problem if (a + b) < 2 r ( otherwise overflow detected ) - a + b - a + b = 2 r+1 – a + b = b –a modulo 2 r+1 for b  a = 2 r+1 – (a - b ) for b  a

18 Floating point numbers Decimal –Example: + 0.234567 x 10 9 sign mantissa exponent

19 Binary floating point (IEEE standard) Binary: –single- (32 bits), double- (64 bits), extended precision (80 bits) S E = exponent F = mantissa 1 8 bits 23 bits To find E and F, write a binary number as 1. a 1 a 2 a 3 a 4 … 2 x –F = a 1 a 2 a 3 a 4 … –E = 127 + x range of x: -126 ≤ x ≤ 128 The number 0.0 is represented by all 0’s Infinity is represented by all 1’s in the exponent and 0’s in the mantissa Number = (-1) S (1+F)(2 E-127 )

20 Hexadecimal numbers Widely used in computer and microprocessor applications Base is 16: Decimalbinary hexadecimal –000000 –100011 –200102 –300113 –401004 –501015 –601106 –701117 –810008 –910019 –101010A –111011B –121100C –131101D –141110E –151111F

21 Hexadecimal numbers (count) 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 etc. i.e. In decimal13 16 means 1 x 16 + 3 2C 16 means 2 x 16 + 12 A2B 16 means 10 x 16 2 + 2 x 16 1 + 11 With 2 hexadecimal digits we can count up to FF 16 = 255 decimal Each hexadecimal character represents a 4-bit number!

22 Hexadecimal numbers (examples) Example Binary to hexadecimal 1100 1010 0101 0111 0011 1111 0001 0110 1001 C A 5 7 3 F 1 6 9 Example Hexadecimal to binary 6BD3 = 6 x 16 3 + 11 x 16 2 + 13 x 16 1 + 3 in binary: 0110 1011 1101 0011

23 octal numbers used in computer and microprocessor applications Base is 8: Decimalbinary octal –0 0000 –1 0011 –2 0102 –3 0113 –4 1004 –5 1015 –6 1106 –7 1117 –8100010 –9100111 –10101012 –11101113 –12110014 –13110115 –14111016 –15111117

24 octal numbers (count) 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 22 23 24 25 26 27 30 etc. i.e. In decimal13 8 means 1 x 8 + 3 21 8 means 2 x 8 + 1 327 8 means 3 x 8 2 + 2 x 8 1 + 7 With 2 octal digits we can count up to 77 8 = 63 decimal Each octal character represents a 4-bit number!

25 octal numbers (examples) Example Binary to octal 100 010 101 111 011 111 001 110 001 4 2 5 7 3 7 1 6 1 Example octal to binary 6233 = 6 x 8 3 + 2 x 8 2 + 3 x 8 1 + 3 in binary: 110 010 011 011

26 octal numbers (examples) Conversion digital to octal Example: 359 decimal = 5 x 8 2 (320) + 4 x 8 (32) + 7

27 Binary Coded Decimal Conversion table DecimalBCD 00000 10001 20010decimal 35 = 0011 0101 BCD 30011decimal 98 = 1001 1000 BCD 40100 501011000 0110 BCD = 86 decimal 60110 70111 81000 91001

28 Some other codes DecimalBCD 1-out-of-10 Biquinary Binary coded decimal 000001000000000 0100001 100010100000000 0100010 20010 0010000000 0100100 30011 0001000000 0101000 40100 0000100000 0110000 50101 0000010000 1000001 60110 0000001000 1000010 70111 0000000100 1000100 81000 0000000010 1001000 91001 0000000001 1010000 Application: error detection (check!)

29 Gray Code By example for binary words of length 3 # codeword 0 000 numbers differ by 1 binary difference 1 1 001 2 011 3 010 Homework: design a general code for length n 4 110 5 111 6 101 7 100

30 parity An extra bit is added to a string to make the number of 1’s always even (or odd if desired) –i.e. the parity for 011 is 0 01 1 0 the parity for 111 is 11 1 1 1 RESULT: any odd number of changes detectable!


Download ppt "DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck."

Similar presentations


Ads by Google