CH 05
CH 05
CH 05
4) When the number to be expressed is outside of the integer range of the computer (too large or
too small), or when the number contains a fractional part it must be stored as a(n)
a) constant.
b) exponent.
c) complement.
d) real number.
5) An 8-bit storage location can store any unsigned integer of value between 0 and
a) 7
b) 16
c) 255
d) 512
Section 5.1 Unsigned Binary and Binary-Coded Decimal Representations
9) What is the most common way to represent negative integers in binary form?
a) As BCD
b) Using 2's complement
c) Using sign-and-magnitude
d) None of the above
11) A combination of numbers that produces a result outside the available range is known as
a) overload.
b) overflow.
c) spillover.
d) wraparound.
13) Using sign-and-magnitude representation, the largest positive number that can be stored in 8
bits is
a) 7
b) 127
c) 255
d) 512
15) If both inputs to an addition have the same sign, and the output sign is different then
a) the leftmost bit should wrap around.
b) the leftmost bit should be disregarded.
c) the range is insufficient to hold the result.
d) you must take the complement of the result.
Section 5.2 Representations for Signed Integers
17) In 1's and 2’s complement representations, a negative number begins with
a) -1
b) 0
c) 1
d) -0
20) When adding two numbers using 2's complement, carries beyond the leftmost digit are
a) inverted.
b) ignored.
c) shifted left.
d) shifted right.
22) To correct for carries and borrows that occur when large numbers must be separated into
parts to perform additions and subtractions, we use
a) a bit hold.
b) a carry flag.
c) an error flag.
d) an overflow flag.
27) The leftmost bit in an IEEE standard floating point number represents
a) the exponent.
b) the mantissa.
c) the sign of the mantissa.
d) the sign of the exponent.
29) In the IEEE 754 standard 32 bit single-precision floating point format, how many bits are
allocated to the exponent?
a) 1
b) 2
c) 7
d) 8
29) In the IEEE 754 standard 32 bit single-precision floating point format, how many bits are
allocated to the mantissa?
a) 8
b) 16
c) 23
d) 24
32) In the normalized IEEE 754 standard 32 bit single-precision floating point format, the
leading bit of the mantissa is
a) the sign bit.
b) not stored.
c) always a zero.
d) used for larger exponents.
33) In the IEEE 754 standard 32 bit single-precision floating point format the number "zero" is
a) impossible to represent.
b) treated as a special case.
c) has a mantissa of all ones.
d) has an exponent of all ones.
34) The Department of Motor Vehicles is developing a software program that uses a variable to
count the number of cars being sold each day. The maximum number of cars sold is expected to
be several million over the life of the program and there are no fractional sales. What data type
will you use for this variable?
a) float 32-bit
b) float 64-bit
c) integer long 64-bit
d) integer short 32-bit
1) Calculate largest positive integer that can be stored in 2 bytes using a) an unsigned integer
b) an integer using sign and magnitude, and c) an unsigned BCD number.
Sol: This is useful: The relationship between largest positive integer and the number (n) of
bits used is
b) In two bytes there are 16 bits, of those 15 are available for positive numbers:
= 2^15 – 1
= 32768 – 1
= 32,767
2) How does overflow occur when using a fixed word size to represent integers?
Sol: from the text: “A fixed word size results in a range of some particular fixed size; it is
always possible to have a combination of numbers that produces a result outside the range.
This condition is known as overflow.”
a) Find the 9’s complementary representation for the three-digit number -351.
b) Find the 9’s complementary representation for the four-digit number -351.
Sol:
a) In three-digits, the 9’s complementary representation is
999
- 351
-----------
648
Sol:
a) In 9’s complement, numbers 0 to 499 are positive, hence 461 is +461.
b) In 9’s complement, numbers 500 to 998 are negative, so we find the complement:
999
-747
-------------
252
5) Two's complement
Sol:
a) Step 1: 51 in binary using 8-bits is 00110011
Step 2: Flip the bits: 11001100
Step 3: add 1: 11001101
b) Step 1: 331 in binary using 16-bits is 0000 0001 0100 1011
Step 2: Flip the bits: 1111 1110 1011 0100
Step 3: add 1: 1111 1110 1011 0101
6) Two's complement.
a) What is the decimal sign-and-magnitude value of the 8-bit number represented in 2's
complement by 11010011?
b) What is the decimal sign-and-magnitude value of the 8-bit number represented in 2's
complement by 01000011?
Sol:
a) Since the leftmost digit is 1, the number is negative. So, invert the number and add one:
11010011 --> 00101100 + 1 = 45. Include the negative sign -45.
b) Since the leftmost digit is 0, the number is positive. So, just convert to decimal:
01000011 (base 2) = 67 (base 10).
7) The exponent for a given number is negative 25. What value is stored to represent the
exponent in excess-50 notation?
Sol: In excess-50 notation, 50 is the midvalue or offset. So, we subtract 25 from 50 = 25.
8) What purpose is served by "normalizing" the mantissa? That is—given the extra work—
what is gained?
Sol: Moving the decimal point such that there are no leading zeros ensures the fewest
number of significant digits are truncated, which maximizes the precision.
From the text: “To maximize the precision for a given number of digits, numbers will be
stored whenever possible with no leading zeros. This means that, when necessary, numbers
are shifted left by increasing the exponent until leading zeros are eliminated. This process
is called normalization.”
Section 5.3 Real Numbers
In problems 9-13 use the floating point format SEEMMMMM, where S = 0 is "+" and 5 is "-";
EE is the exponent in excess-50, and MMMMM are five digits of mantissa.
Sol:
12.25 = .1225 x 10^2
S=0
EE=52
MMMMM = 12250, where the added zero is added to make five digits
Answer: 05212250
Sol:
0.00012325 = .1225 x 10^-4
S=5
EE=46
MMMMM = 12325
Answer: 54612325
Sol:
5 = S; sign is negative
56 = EE; exponent is 6
98799 = MMMMM
- .98799 x 10^6 = -987990.
12) Add the two numbers 04933460 and 04877456 (in SEEMMMMM format.) Represent your
answer in decimal form without using exponents.
Sol:
04933460 ---> +.33460 x 10 ^-1 or 0.033460
04877456 ---> +.77456 x10 ^-2 or 0.0077456
0.033460 + 0.0077456 = 0.0412056
13) Multiply the two numbers 05312675 and 05144359 (in SEEMMMMM format.) Leave the
answer in SEEMMMMM rounding if necessary.
Sol:
14) What are the trade-offs between integer and floating calculations?
Sol: From the text: “The trade-offs between integer and floating point are clear. Integer
calculations are easier for the computer to perform, have the potential to provide higher
precision, and are obviously much faster to execute. Integer values usually take up fewer
storage locations. As you will see later, it takes a certain amount of time to access each
storage location; thus, the use of fewer storage locations saves time, as well as space.”
15) Suppose you are writing a program that needs to represent a maximum 50,000 whole things
(i.e. integer data type). What would be better: to use a short integer (16 bits) or long integer (64
bits)? Why?
Sol:
First check that 16 bits is sufficient: 2^16 = 65,536 greater than 50,000, so it possible to use
short integer.
From the text: “The longer integer formats may require multiple-word calculation
algorithms, and as such are slower to execute than short formats. The short format is
preferable when it is sufficient for the values that you expect. It may also be necessary to
consider the limitations of other systems that the same program may have to operate on.”