Sec 42 B
Sec 42 B
Sec 42 B
30. It can be shown that every integer can be uniquely represented in the form
ek3k
where ej = -1 , 0, or 1 for j = 0, 1,2, ... , k. Expansions of this type are called balanced ternary expansions. Find the balanced ternary expansions of a) 5. b) 13. c)37. d) 79. 31. Show that a positive integer is divisible by 3 if and only if the sum of its decimal digits is divisible by 3.
than one's complement representations. To represent an integer x with _2n - 1 ::: x ::: 2n - 1 - 1 for a specified positive integer n , a total of n bits is used. The leftmost bit is used to represent the sign. A 0 bit in this position is used for positive integers, and a 1 bit in this position is used for negative integers, just as in one's complement expansions. For a positive integer, the remaining bits are identical to the binary expansion of the integer. For a negative integer, the remaining bits are the bits of the binary expansion of 2 n - 1 - Ix I. Two's complement expansions of integers are often used by computers because addition and subtraction of integers can be performed easily using these expansions, where these integers can be either positive or negative. 40. Answer Exercise 34, but this time find the two's complement expansion using bit strings of length six.
41. Answer Exercise 35 if each expansion is a two's complement expansion of length five . .
2+ ao.
46. Give a simple algorithm for forming the two's complement representation of an integer from its one's complement representation.
47. Sometimes integers are encoded by using four-digit binary expansions to represent each decimal digit. This produces the binary coded decimal form of the integer. For instance, 791 is encoded in this way by 01111001O00l. How many bits are required to represent a number with n decimal digits using this type of encoding? A Cantor expansion is a sum of the form
d) 11111
where ai is an integer with 0 ::: ai ::: i for i = 1, 2, ... , n. 48. Find the Cantor expansions of a) 2. b) 7. c) 19. d) 87. e) 1000. f) 1,000,000. *49. Describe an algorithm that finds the Cantor expansion of an integer.
36. If m is a positive integer less than 2n - l, how is the one's complement representation of -m obtained from the one's complement of m , when bit strings of length n are used? 37. How is the one's complement representation of the sum of two integers obtained from the one's complement representations of these integers? 38. How is the one's complement representation of the difference of two integers obtained from the one's complement representations of these integers? 39. Show that the integer m with one's complement representation (a n-lan- 2 ... alao) can be found using the equation m = -an-l (2n - 1 - 1) + an_22n-2 + ... + al 2 + aO . Two's complement representations of integers are also used to simplify computer arithmetic and are used more commonly
* 50.
51. Add (lOl11h and (1l010h by working through each step of the algorithm for addition given in the text. 52. Multiply (lllOh and (1010h by working through each step of the algorithm for multiplication given in the text. 53. Describe an algorithm for finding the difference of two binary expansions . 54. Estimate the number of bit operations used to subtract two binary expansions.