14 CHAPTER 2.DATA REPRESENTATIONS Binary Hexadecimal Unsigned Int Signed Int 00000000000000000000000000000000 00000000 0 0 00000000000000000000000000000001 00000001 1 1 00000000000000000000000000000010 00000002 2 2 00000000000000000000000000000011 00000003 3 3 00000000000000000000000000000100 00000004 4 00000000000000000000000000001111 0000000F 15 15 00000000000000000000000000010000 00000010 16 16 00000000000000000000000000010001 00000011 17 17 01111111111111111111111111111110 7FFFFFFE 2147483646 2147483646 01111111111111111111111111111111 7FFFFFFF 2147483647 2147483647 10000000000000000000000000000000 80000000 2147483648 -2147483648 10000000000000000000000000000001 80000001 2147483649 -2147483647 11111111111111111111111111111100 FFFFFFFC 4294967292 -4 11111111111111111111111111111101 FFFFFFFD 4294967293 -3 11111111111111111111111111111110 FFFFFFFE 4294967294 -2 11111111111111111111111111111111 FFFFFFFF 4294967295 -1
14 CHAPTER 2. DATA REPRESENTATIONS Binary Hexadecimal Unsigned Int Signed Int 00000000000000000000000000000000 00000000 0 0 00000000000000000000000000000001 00000001 1 1 00000000000000000000000000000010 00000002 2 2 00000000000000000000000000000011 00000003 3 3 00000000000000000000000000000100 00000004 4 4 . . . . . . . . . . . . 00000000000000000000000000001111 0000000F 15 15 00000000000000000000000000010000 00000010 16 16 00000000000000000000000000010001 00000011 17 17 . . . . . . . . . . . . 01111111111111111111111111111110 7FFFFFFE 2147483646 2147483646 01111111111111111111111111111111 7FFFFFFF 2147483647 2147483647 10000000000000000000000000000000 80000000 2147483648 -2147483648 10000000000000000000000000000001 80000001 2147483649 -2147483647 . . . . . . . . . . . . 11111111111111111111111111111100 FFFFFFFC 4294967292 -4 11111111111111111111111111111101 FFFFFFFD 4294967293 -3 11111111111111111111111111111110 FFFFFFFE 4294967294 -2 11111111111111111111111111111111 FFFFFFFF 4294967295 -1
2.7.PROBLEMS 15 2.7 Problems 1.octal octal octal Note:An "octal"is a number represented by only 3 bits Consider a fictitious computer,one that can only do 3-bit binary arithmetic.(Anything past the 3'rd bit can not be represented.See the notes for Lecture 2 for some related examples.)Complete the following addition table,that is,add the octal in i'th row to the octal in the j'th column and put the resultant octal in the box located at the i'th row and j'th column.There are 3 examples worked out for you.For these examples, show your calculations in long-hand. 000001010 011100101110111 000 001 010 011 100 101 010 110 111 011 110 2.octal×octal=octal This is a similar exercise to the above except that you are to multiply the octals.Be sure to show your work for the 3 examples given. 000001 010011100 101110111 000 001 010 011 100 101 001 110 111 100 001
2.7. PROBLEMS 15 2.7 Problems 1. octal + octal = octal Note: An “octal” is a number represented by only 3 bits. Consider a fictitious computer, one that can only do 3-bit binary arithmetic. (Anything past the 3’rdbit can not be represented. See the notes for Lecture 2 for some related examples.) Complete the following addition table, that is, add the octal in i’th row to the octal in the j’th column andput the resultant octal in the box locatedat the i’th row and j’th column. There are 3 examples workedout for you. For these examples, show your calculations in long-hand. 000 001 010 011 100 101 110 111 000 001 010 011 100 101 010 110 111 011 110 2. octal × octal = octal This is a similar exercise to the above except that you are to multiply the octals. Be sure to show your work for the 3 examples given. 000 001 010 011 100 101 110 111 000 001 010 011 100 101 001 110 111 100 001
16 CHAPTER 2.DATA REPRESENTATIONS 3.Bits,nibbles and integers.Is it a hex? Your imaginary computer represents integers using 4 and only 4 bits!The result of an arithmetic operation with two integers always results in a 4-bit result.Higher-order bits are "lost'”. The following table shows the binary,hexadecimal,unsigned integer,and signed inte- ger representations for all the possible bit patterns that can be represented by your computer. Binary Hexadecimal Unsigned Int Signed Int 0000 0 0 0 0001 1 1 0010 2 2 2 0011 3 3 3 0100 0101 5 5 5 0110 6 6 6 0111 7 7 7 1000 8 8 -8 1001 9 9 -7 1010 a or A 10 -6 1011 b or B 11 -5 1100 c or C 12 -4 1101 d or D 13 -3 1110 e or E 14 -2 1111 f or F 15 -1 Do your calculations in binary arithmetic and SHOW YOUR WORK!Quote your results of your calculations in binary,integer,unsigned and hexadecimal integer repre- sentations. (a)What is the sum of the integers 2 and 3? (b)What is the sum of the integers-2 and-3? (c)What is the sum of the integers-8 and-8? (d)What is the product of the integers 2 and 3? (e)What is the product of the integers-2 and-3? (f)What is the product of the integers-8 and-8?
16 CHAPTER 2. DATA REPRESENTATIONS 3. Bits, nibbles and integers. Is it a hex? Your imaginary computer represents integers using 4 andonly 4 bits! The result of an arithmetic operation with two integers always results in a 4-bit result. Higher-order bits are “lost”. The following table shows the binary, hexadecimal, unsignedinteger, andsignedinteger representations for all the possible bit patterns that can be representedby your computer. Binary Hexadecimal Unsigned Int Signed Int 0000 0 0 0 0001 1 1 1 0010 2 2 2 0011 3 3 3 0100 4 4 4 0101 5 5 5 0110 6 6 6 0111 7 7 7 1000 8 8 -8 1001 9 9 -7 1010 a or A 10 -6 1011 b or B 11 -5 1100 c or C 12 -4 1101 dor D 13 -3 1110 e or E 14 -2 1111 f or F 15 -1 Do your calculations in binary arithmetic and SHOW YOUR WORK! Quote your results of your calculations in binary, integer, unsignedandhexadecimal integer representations. (a) What is the sum of the integers 2 and3? (b) What is the sum of the integers -2 and-3? (c) What is the sum of the integers -8 and-8? (d) What is the product of the integers 2 and3? (e) What is the product of the integers -2 and-3? (f) What is the product of the integers -8 and-8?
2.7.PROBLEMS 17 4.The interbreeding hex:hex hex hex Consider a fictitious computer,one that can only do 4-bit binary arithmetic.(Anything past the 4'th bit can not be represented.See the notes for Lecture 2 for some related examples.)Complete the following addition table,that is,add the hex in i'th row to the hex in the ith column and put the resultant hex in the box located at the i'th row and j'th column.Some of the answers are given to you.Fill in the empty boxes. Remember that addition commutes.Therefore the actual work is halved and you need not do the boxes that are filled with X's. 0 12345 6 78 9A B DE F 0 0 X X X X X X X X X X 1 2 2 4 X X 3 3 4 6 X X X 4 4 5 8 X X 5 5 a X X 6 6 7 c 7 7 8 8 8 9 0X X X X 9 9 a 2 X X X X X X A a b 4 X X X B b 6 X X C C d 8 X X X D d X X E e c X F f 0 e
2.7. PROBLEMS 17 4. The interbreeding hex: hex + hex = hex Consider a fictitious computer, one that can only do 4-bit binary arithmetic. (Anything past the 4’th bit can not be represented. See the notes for Lecture 2 for some related examples.) Complete the following addition table, that is, add the hex in i’th row to the hex in the j’th column andput the resultant hex in the box locatedat the i’th row and j’th column. Some of the answers are given to you. Fill in the empty boxes. Remember that addition commutes. Therefore the actual work is halved and you need not do the boxes that are filled with X’s. + 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 0 X X X X X X X X X X X X X X X 1 1 2 X X X X X X X X X X X X X X 2 2 3 4 X X X X X X X X X X X X X 3 3 4 6 X X X X X X X X X X X X 4 4 5 8 X X X X X X X X X X X 5 5 6 a X X X X X X X X X X 6 6 7 c X X X X X X X X X 7 7 8 e X X X X X X X X 8 8 9 0 X X X X X X X 9 9 a 2 X X X X X X A a b 4 X X X X X B b c 6 X X X X C c d 8 X X X D d e a X X E e f c X F f 0 e
18 CHAPTER 2.DATA REPRESENTATIONS 5.Oh,hex,won't it ever stop:hex x hex hex This is a similar exercise to the previous one except that you are to multiply the hexes. X 0 2 3 4 5 6 7 8 9 D E F 0 0 X X 1 0 X X 2 0 2 3 0 3 0 X X 4 0 4 0 X 5 0 5 9 X X 6 0 6 4 X 7 0 7 X X 8 0 8 9 0 9 X 0 a 4 X X X B 0 b 9X X X X 0 0 X X D 0 d 9X X E 0 4 X F 0 1
18 CHAPTER 2. DATA REPRESENTATIONS 5. Oh, hex, won’t it ever stop: hex × hex = hex This is a similar exercise to the previous one except that you are to multiply the hexes. X 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 0 X X X X X X X X X X X X X X X 1 0 1 X X X X X X X X X X X X X X 2 0 2 4 X X X X X X X X X X X X X 3 0 3 9 X X X X X X X X X X X X 4 0 4 0 X X X X X X X X X X X 5 0 5 9 X X X X X X X X X X 6 0 6 4 X X X X X X X X X 7 0 7 1 X X X X X X X X 8 0 8 0 X X X X X X X 9 0 9 1 X X X X X X A 0 a 4 X X X X X B 0 b 9 X X X X C 0 c 0 X X X D 0 d 9 X X E 0 e 4 X F 0 f 1