1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems
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;
3 Objectives (Cont’d) n State the methods of complements in representing negative numbers; and n Perform binary subtraction using complement representations.
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.
5 References (Cont’d) n Thomas C. Bartee, “Digital Computer Fundamentals,” sixth edition, McGraw-Hill Publishing Company.
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.
7 Data Representations n Computers use strings of bits to represent numbers, letters, punctuation marks, and any other useful pieces of information.
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.
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.
10 Alphanumeric Codes n EBCDIC: Extended Binary Coded Decimal Interchange Code. 8-bit IBM code.
11 Numbers n In principal, represented in binary numbering system. n variations, such as integers, floating point numbers, negative numbers, etc.
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 Positional significance exists.
13 Example n =5 =
14 Positional Significance n N b =S i S i S 2 S 1 S 0. S -1 S -2 S S -k =S i b i + S i-1 b i S 2 b 2 + S 1 b 1 + S 0 b 0 + S -1 b -1 + S -2 b -2 + S -3 b S -k b -k (Exp. 1.) n The Least Significant Digit (LSD), S -k, and the Most Significant Digit (MSD), S i.
15 Integers n Represented in binary numbering system n For example, , represents : 1 2 0 = =11 10
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 n Bigger numbers, long integers may occupy 32 bits or 64 bits.
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 as n Non-positional. n Complicated in arithmetic.
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.
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.
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.
21 Floating point numbers (Cont ’ d) n Example: n The leftmost bit is a zero, i.e positive. n The next seven bits, , are exponent equivalent to the decimal number 66 n The final 24 bits indicate the mantissa
22 Floating point numbers (Cont ’ d) n The machine number represents, in decimal: + ( ) = n To ensure uniqueness of representation and obtain all the available precision of the system, M e -1.
23 Floating point numbers (Cont ’ d) n The smallest positive machine number that can be represented is = n while the largest is =
24 Floating point numbers (Cont ’ d) n Numbers less than result in what is called underflow, and are often set to zero. n Numbers greater than result in an overflow condition and cause the computations to halt.
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.
26 Base numbers n In our daily life, for convenience the base number is always ignored such that means n In computer world, the representation can be a value in other numbering systems. n is different from
27 Base numbers n According to the nature of positional significance, n equals to n equals to n When dealing with numeric values in different systems, the number indicating the base must also be present.
28 Number Conversions n Conversion to decimal numbers n Conversions among binary, octal, and hexadecimal numbers
29 Conversion to decimal numbers n Simply using the polynomial expression stated in Exp. 1.1 n = 1 2 0 = =
30 Conversion to decimal numbers (Cont ’ d) n = 1 8 0 = = n A1D 16 = 10 16 0 = =
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 S 2 S 1 S 0 n From Exp. 1.1, we have: N 10 =S i b i + S i-1 b i S 2 b 2 + S 1 b 1 + S 0 b 0
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.
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.
34 Conversion from decimal numbers (Cont ’ d) n The equivalent are , 612 8, and 18A 16
35 Conversions among binary, octal, and hexadecimal numbers
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.
37 Conversions from octal or hexadecimal to binary numbers n n 18A A
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.
39 Conversions from binary to octal or hexadecimal numbers n Leading zero
40 Conversions from binary to octal or hexadecimal numbers Leading zeros 2 A C B n The equivalents of are and 2ACB 16.
41 Conversions between octal and hexadecimal numbers n No direct method n Through the binary conversions.
42 Binary Arithmetic
43 Binary Arithmetic (Cont ’ d) n The rules are simple. n They are similar to the decimal arithmetic.
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.
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.
46 Sign bit representation n Negative number represented by a sign preceding its absolute value, e.g 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.
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, represents , or +5 10, while means , or
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.
49 Sign bit representation (Cont ’ d)
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.
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 n - 1) - N 2
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.
53 1’s complement (Cont ’ d) n 1's complement number of : n n = 8. N' 2 = ( ) - N 2 = ( ) = =
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 = N ’ where N ’ 2 is the 1’s complement representation of the number.
55 2’s complement (Cont ’ d) n No duplicate representation for all numbers. N 2 = N’ 2 = N” 2 =N’ 2 + 1= n Since only 8 bits are used, the base complement of zero is zero, too.
56 2’s complement (Cont ’ d) n With 8-bit 2's complement representation, total 256 numbers ( ) to (0 10 ) to ( ).
57 2’s complement (Cont ’ d) n 2's complement number of ’ s complement, N' is N ” = N ’ + 1 = =
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 n n If X > Y, the sum will produce an end carry, 2 n, which can be discarded, and the sum is positive.
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 ).
60 Subtraction with 2’s complements (Cont ’ d) n Example: = = = (in 2’s complement)
61 Subtraction with 2’s complements (Cont ’ d)
62 Subtraction with 2’s complements (Cont ’ d) n Example: = = = (in 2’s complement)
63 Subtraction with 2’s complements (Cont ’ d)