Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.

Similar presentations


Presentation on theme: "1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems."— Presentation transcript:

1

2 1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems

3 2 Objectives n Describe the different methods of data representations; n Describe the characteristics of number representation; n Convert a number in any numbering base to other bases; n Perform binary arithmetic;

4 3 Objectives (Cont’d) n State the methods of complements in representing negative numbers; and n Perform binary subtraction using complement representations.

5 4 References n Richard S. Sandige, “Modern Digital Design,” Mcgraw-Hill Publishing Company. n Theodore F. Bogart Jr., “Introduction to Digital Circuits,” McGraw-Hill Publishing Company.

6 5 References (Cont’d) n Thomas C. Bartee, “Digital Computer Fundamentals,” sixth edition, McGraw-Hill Publishing Company.

7 6 Data Representations n Values in digital systems consist of only 0 and 1. n A combination containing a single 0 or 1 is called a bit (Binary digit). n In general, n bits can be used to distinguish amongst 2 n distinct entities.

8 7 Data Representations n Computers use strings of bits to represent numbers, letters, punctuation marks, and any other useful pieces of information.

9 8 Alphanumeric Codes n An alphanumeric code is the assignment of letters and other characters to bit combinations. n These include letters, digits and special symbols. n ASCII: American Standard Code for Information Interchange.

10 9 Alphanumeric Codes n 7-bit to represent 128 different symbols including upper-case and lower-case letters, digits and special symbols, printable and non-printable. n 8-bit extension uses the eighth bit to add error-detecting capability (parity check) for transferring codes between computers.

11 10 Alphanumeric Codes n EBCDIC: Extended Binary Coded Decimal Interchange Code. 8-bit IBM code.

12 11 Numbers n In principal, represented in binary numbering system. n variations, such as integers, floating point numbers, negative numbers, etc.

13 12 Characteristics of Number representation n Binary numbering system; some characteristics being the same as decimal n A numeric value is represented by a series of symbols. n five thousand two hundred and thirty two represented by 5232. Positional significance exists.

14 13 Example n 5472.26 =5  10 3 + 4  10 2 + 7  10 1 + 2  10 0 + 2  10 -1 + 6  10 -2 =5000 + 400 + 70 + 2 + 0.2 + 0.06

15 14 Positional Significance n N b =S i S i-1...... S 2 S 1 S 0. S -1 S -2 S - 3...... S -k =S i b i + S i-1 b i-1 +...... + S 2 b 2 + S 1 b 1 + S 0 b 0 + S -1 b -1 + S -2 b -2 + S -3 b -3 +...... + S -k b -k (Exp. 1.) n The Least Significant Digit (LSD), S -k, and the Most Significant Digit (MSD), S i.

16 15 Integers n Represented in binary numbering system n For example, 1011 2, represents : 1  2 3 + 0  2 2 + 1  2 1 + 1  2 0 =8 + 0 + 2 + 1 =11 10

17 16 Integers (Cont ’ d) An integer usually employs 2 bytes, i.e. 16 bits, which can represent a number up to (2 16 – 1) or 65535. n Bigger numbers, long integers may occupy 32 bits or 64 bits.

18 17 Binary Coded Decimal (BCD) n Integer representation. n The decimal digits are stored in terms of their 4-bits binary equivalents n For example: decimal number 9502 would be stored as1001 010100000010 n Non-positional. n Complicated in arithmetic.

19 18 Floating point numbers n Used when a number is very large or very small. n A pair of numbers to represent the values. n One is the value scaled to a standard form, the normalized mantissa in fixed-point notation. n The other is a scaling factor, the exponent.

20 19 Floating point numbers (Cont ’ d) n Scientific notation, i.e. M  b e, where M is the mantissa; b the base and e the exponent. n Example, single-precision floating- point number in IBM 370 or 3000 series: n 1-bit sign indicator, a 7-bit exponent with a base of 16, and a 24-bit mantissa.

21 20 Floating point numbers (Cont ’ d) n 24 bits correspond to 6-7 decimal digits, we can assume that a number has at least 6 decimal digits of precision. n The exponent of 7 bits gives a range of 0 to 127. Because of an exponential bias, the range is actually -64 to +63, that is, 64 is automatically subtracted from the listed exponent.

22 21 Floating point numbers (Cont ’ d) n Example: 0 1000010 01100110000010000000000 n The leftmost bit is a zero, i.e positive. n The next seven bits, 1000010, are exponent equivalent to the decimal number 66 n The final 24 bits indicate the mantissa

23 22 Floating point numbers (Cont ’ d) n The machine number represents, in decimal: + ( 2 -1 + 2 -3 + 2 -4 + 2 -7 + 2 -8 + 2 -14 )  16 66-64 = 179.015625. n To ensure uniqueness of representation and obtain all the available precision of the system, M  e -1.

24 23 Floating point numbers (Cont ’ d) n The smallest positive machine number that can be represented is 0 0000000 000100000000000000000000 = 16 -65  10 -78 n while the largest is 0 1111111 111111111111111111111111 = 16 63  10 76.

25 24 Floating point numbers (Cont ’ d) n Numbers less than 16 -65 result in what is called underflow, and are often set to zero. n Numbers greater than 16 63 result in an overflow condition and cause the computations to halt.

26 25 Commonly used Numbering Systems n Binary number system (base 2), octal (base 8), and hexadecimal (base 16) number systems. n Computers only deal with binary numbers, the use of the octal and hexadecimal numbers is solely for the convenience of human people.

27 26 Base numbers n In our daily life, for convenience the base number is always ignored such that 5472.26 means 5472.26 10. n In computer world, the representation 5472.26 can be a value in other numbering systems. n 5472.26 8 is different from 5472.26 16.

28 27 Base numbers n According to the nature of positional significance, n 5472.26 8 equals to 2874.34375 10 n 5472.26 16 equals to 21618.1484375 10 n When dealing with numeric values in different systems, the number indicating the base must also be present.

29 28 Number Conversions n Conversion to decimal numbers n Conversions among binary, octal, and hexadecimal numbers

30 29 Conversion to decimal numbers n Simply using the polynomial expression stated in Exp. 1.1 n 11001001 2 = 1  2 7 + 1  2 6 + 0  2 5 + 0  2 4 + 1  2 3 + 0  2 2 + 0  2 1 + 1  2 0 = 128 + 64 + 8 + 1 = 201 10

31 30 Conversion to decimal numbers (Cont ’ d) n 1307 8 = 1  8 3 + 3  8 2 + 0  8 1 + 7  8 0 = 512 + 192 + 0 + 7 = 711 10 n A1D 16 = 10  16 2 + 1  16 1 + 13  16 0 = 2560 + 16 + 13 = 2589 10

32 31 Conversion from decimal numbers n Given a decimal number, N 10, its equivalent representation in base b is as n S i S i-1...... S 2 S 1 S 0 n From Exp. 1.1, we have: N 10 =S i b i + S i-1 b i-1 +...... + S 2 b 2 + S 1 b 1 + S 0 b 0

33 32 Conversion from decimal numbers (Cont ’ d) n Steps : i. Divide the decimal number by the base number and obtain the quotient and the remainder. ii.Take away the remainder and regard the quotient as the new decimal number. iii.Repeat the steps 1 and 2 until the quotient is 0. iv.The equivalent number in base b is obtained by writing the remainder in reverse sequence.

34 33 Conversion from decimal numbers (Cont ’ d) n To obtain the binary equivalent, use 2 as the base, b, in division. n To find the octal and hexadecimal equivalent numbers, the base number will be 8 and 16 respectively. n In all cases, the remainders will always be less than the base numbers.

35 34 Conversion from decimal numbers (Cont ’ d) n The equivalent are 110001010 2, 612 8, and 18A 16

36 35 Conversions among binary, octal, and hexadecimal numbers

37 36 Conversions from octal or hexadecimal to binary numbers n Each octal digit comprises three binary digits and each hexadecimal digit comprises four binary digits. n Conversion to a binary number from an octal or hexadecimal number is simply replacing all octal or hexadecimal digits by their binary equivalents.

38 37 Conversions from octal or hexadecimal to binary numbers n 612 8 6 1 2       110001010 n 18A 16 1 8 A       000110001010

39 38 Conversions from binary to octal or hexadecimal numbers n To group the binary digits into groups of three or four, then replace each group with their octal or hexadecimal equivalent digits. n Grouping must start from the radix point. n Leading zeros can be added if necessary.

40 39 Conversions from binary to octal or hexadecimal numbers n 10101011001011 2 Leading zero  010 101 011 001 011      2 5 3 1 3

41 40 Conversions from binary to octal or hexadecimal numbers Leading zeros  0010101011001011     2 A C B n The equivalents of 10101011001011 2 are 25313 8 and 2ACB 16.

42 41 Conversions between octal and hexadecimal numbers n No direct method n Through the binary conversions.

43 42 Binary Arithmetic

44 43 Binary Arithmetic (Cont ’ d) n The rules are simple. n They are similar to the decimal arithmetic.

45 44 Binary Arithmetic (Cont ’ d) n Multiplication and division employ the principles of addition and subtraction respectively. n Subtraction can be regarded as addition by adding a negative number. n All arithmetic problems can be solved using the principles of addition provided.

46 45 Negative numbers n Two ways to represent a negative binary number. u a signed bit to represent the positive or negative sign. u the complemented form of the positive number to represent a negative value.

47 46 Sign bit representation n Negative number represented by a sign preceding its absolute value, e.g. -65. n Similar technique can be employed to represent a negative binary number. n To attach one digit to the binary number to represent the sign. n This binary digit as the sign bit.

48 47 Sign bit representation (Cont ’ d) n A number with sign bit is called signed number. n Sign bit is always the MSB. n The number is positive if the sign bit is 0 and is negative if the sign bit is 1. n For example, 00101 2 represents +0101 2, or +5 10, while 10101 2 means -0101 2, or -5 10.

49 48 Sign bit representation (Cont ’ d) n The advantage is simple. n Disadvantages u Duplication in representing zero. u addition to a signed negative number gives an incorrect answer.

50 49 Sign bit representation (Cont ’ d)

51 50 Complement representation n The 1’s complement and the 2’s complement. n The most significant bit still represents the sign. n The other digits are not the same.

52 51 1’s complement n The negative value of an n-digit binary number, N 2, can be represented by its 1’s complement, N' 2 n It is equal to the base number, 2, to the power n minus the number N minus one, or: N' 2 = 2 n - N 2 - 1 = (2 n - 1) - N 2

53 52 1’s complement (Cont ’ d) n (2 n - 1) is the largest value that can be represented by an n-digit number in the binary numbering system n N' 2 can be obtained by subtracting each digit with 1, or by inverting all binary digits.

54 53 1’s complement (Cont ’ d) n 1's complement number of 01001101 2 : n n = 8. N' 2 = (2 8 - 1) - N 2 = (100000000 - 1) - 01001101 = 11111111 - 01001101 = 10110010 2

55 54 2’s complement n The 2’s complement, N" 2, of an n- digit binary number, N 2, is defined as: N" 2 = 2 n - N 2 = (2 n - 1) - N 2 + 1 = N ’ 2 + 1 where N ’ 2 is the 1’s complement representation of the number.

56 55 2’s complement (Cont ’ d) n No duplicate representation for all numbers. N 2 =00000000 N’ 2 =11111111 N” 2 =N’ 2 + 1= 1 00000000 n Since only 8 bits are used, the base complement of zero is zero, too.

57 56 2’s complement (Cont ’ d) n With 8-bit 2's complement representation, total 256 numbers 10000000 2 (-128 10 ) to 00000000 2 (0 10 ) to 01111111 2 (+127 10 ).

58 57 2’s complement (Cont ’ d) n 2's complement number of 01001101. 1 ’ s complement, N' is 10110010 N ” = N ’ + 1 = 10110010 + 1 = 10110011

59 58 Subtraction with 2’s complements n Subtraction of two numbers: X 2 - Y 2 =X 2 + (- Y 2 ) In 2 ’ s complement representation: X 2 + (2 n - Y 2 ) = X 2 - Y 2 + 2 n n If X > Y, the sum will produce an end carry, 2 n, which can be discarded, and the sum is positive.

60 59 Subtraction with 2’s complements (Cont ’ d) n If X < Y, the sum is negative and will be 2 n - (Y 2 - X 2 ) which is the 2 ’ s complement of (Y 2 - X 2 ). n (Y 2 - X 2 ) is positive. n The sum is negative with the absolute value being (Y 2 - X 2 ).

61 60 Subtraction with 2’s complements (Cont ’ d) n Example: 93 - 65 +93= 01011101 2 -65= 100000000-01000001 = 10111111(in 2’s complement)

62 61 Subtraction with 2’s complements (Cont ’ d)

63 62 Subtraction with 2’s complements (Cont ’ d) n Example: 65 - 93 +65= 01000001 2 -93= 100000000-01011101 = 10100011(in 2’s complement)

64 63 Subtraction with 2’s complements (Cont ’ d)


Download ppt "1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems."

Similar presentations


Ads by Google