1.1 Convert the binary number 1010100 to decimal format.
Solution
1.2 Convert the binary number 1101.001 to decimal format.
Solution
The digits to the left of the decimal point are treated exactly as in problem 1.1. Thus,
1.3 Convert the binary number 10110001110001.01010111 to decimal format.
Solution
Following the same procedure as in the solution of problem 1.2,
1.4 Write the number 45.0 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32-bit single-precision string.
Solution
(a) To convert 45 to binary form, first find the largest power of 2 that can be divided into 45. This is
. Note that , which is larger than 45. Next, subtract . Now, find the largest
2664=
45 2513=
1.5 Write the number 66.25 in the following forms (in part (c) follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32 bit single-precision string.
Solution
(a) The largest power of 2 that can be divided into 66 is . Next subtract: . Now the
66 262=
1.6 Write the number -0.625 in the following forms (in part (c) follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32 bit single-precision string.
Solution
(a) The largest power of 2 that can be divided into 0.625 is . Next subtract: .
210.5=
0.625 210.125=
1.7 Write the number 0.06298828125 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32-bit single-precision string.
Solution
(a) The largest power of 2 that can be divided into 0.06298828125 is . Next subtract:
. Now the largest power of 2 that can be divided into
240.0625=
0.06298828125 2 40.00048828125=
1.8 Write the number 38.8125 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64-bit double-precision string.
Solution
(a) The largest power of 2 that can be divided into 38 is . Thus, the number 38 in binary form is
2532=
1.9 Write the number –30952 in the following forms (in part (c) follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64 bit double-precision string.
Solution
(a) The largest power of 2 that can be divided into 30952 is . Subtract .
The highest power of 2 that divides into 14568 is . Repeating this process until the largest num-
214 16384=
30952 214
– 14568=
213 8192=
1.10 Write the number 0.197265625 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64-bit double-precision string.
Solution
(a) The largest power of 2 that can be divided into 0.197265625 is . Subtract
230.125=
1.11 Write the number 0.001220703125 in the following forms (in part (c) follow the IEEE-754 stan-
dard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64 bit double-precision string.
Solution
(a) The largest power of 2 that can be divided into 0.001220703125 is . Subtract
. The highest power of 2 that divides into 0.000244140625 is
2100.0009765625=
0.001220703125 2 10
– 0.000244140625=
2120.000244140625=
1.12 In single precision (IEEE-754 standard), 8 bits are used for storing the exponent (the bias is 127),
and 23 bits are used for storing the mantissa.
(a) What are the smallest and the largest positive numbers that can be stored in single precision?
(b) What is the smallest value of the mantissa that can be stored?
Solution
1.13 Suppose a new standard, the IDDD-643 standard, is developed for storing numbers in a string of 16
bits. The first bit is used for the sign of the number (0 if positive and 1 if negative). The next five bits store
the exponent plus the bias, and the remaining 10 bits store the mantissa. The bias is 15 and no bits are
reserved for any special purposes. What is the smallest exponent that can be stored?
Solution
The smallest exponent that can be stored in binary form is 00000, so the exponent plus the bias
1.14 Write the number 581 in the 16-bit IDDD-643 standard that was introduced in Problem 1.13.
Solution
According to the IDDD-643 standard:
Since the number is positive, the first bit is 0
1.15 Write the number 256.1875 in the 16-bit IDDD-643 standard that was introduced in Problem 1.13.
Apply chopping if necessary.
Solution
According to the IDDD-643 standard:
Since the number is positive, the first bit is 0
1.16 What is the number that is actually stored in Problem 1.15? What is the round-off error?
Solution
1.17 Write the number 0.2 in binary form with sufficient number of digits so that the true relative error is
less than 0.01.
Solution
The number 0.2 in binary form is quite long. To express it in binary form with a true relative error of less
than 0.005, we can use Eq. (1.17), but replacing the numerical solution by the approximate solution:
1.18 Consider the function .
(a) Use the decimal format with six significant digits (apply rounding) to calculate (using a calculator)
for .
(b) Use MATLAB (use format long) to calculate the value of and the true relative error, due to
rounding, in the value of that was obtained in part (a).
(c) Multiply by to obtain a form of that is less prone to rounding errors. With the
new form, use the decimal format with six significant digits (apply rounding) to calculate (using a cal-
culator) for . Compare the value with the values in parts (a) and (b).
Solution
(a) To 6 significant digits, and . Thus, retaining 6 signifi-
fx() 1x()cos
x()sin
————————
=
fx()
x0.007=
fx()
fx()
fx()
1x()cos+
1x()cos+
————————
fx()
fx()
x0.007=
0.007()cos 0.999976=
0.007()sin 0.00699994=
fx()
0.007()cos
1.19 Consider the function .
(a) Use the decimal format with six significant digits (apply rounding at each step) to calculate (using a
calculator) for .
(b) Use MATLAB (format long) to calculate the value of . Consider this to be the true value, and
calculate the true relative error due to rounding in the value of that was obtained in part (a).
(c) Multiply by to obtain a form of that is less prone to rounding errors. With the
new form, use the decimal format with six significant digits (apply rounding at each step) to calculate
(using a calculator) for . Compare the value with the values in parts (a) and (b).
Solution
(a) To six significant figures,
fx() 4x+2
x
—————-——–
=
fx()
x0.001=
fx()
fx()
fx()
4x+2+
4x+2+
—————–——-
fx()
fx()
x0.001=
fx() 2.00025 2
0.001
——————-——–0.00025
0.001
—————–0.25===
fx()
1.20 Consider the function .
(a) Use the decimal format with five significant digits (apply rounding) to calculate (using a calculator)
for .
(b) Use MATLAB (format long) to calculate the value of . Consider this to be the true value, and
calculate the true relative error due to rounding in the value of that was obtained in part (a).
Solution
(a) Retaining 5 significant digits,
fx() ex1
x
————
=
fx()
x0.005=
fx()
fx()
1.21 The Taylor series expansion of is given by:
(1.1)
Use the first three terms in Eq. (1.20) to calculate the value of . Use the decimal format with six
significant digits (apply rounding at each step). Calculate the truncation error.
Solution
The quantity π/4 to 6 significant figures with rounding is 0.785398. Using the first three terms in Eq. (1.20)
and evaluating the terms also to 6 significant figures,
x()cos
x()cos 1 x2
2!
—-
x4
4!
—-x6
6!
—-
x8
8!
—-x10
10!
——-
++ +=
π4()cos
1
1.22 Taylor series expansion of the function is:
(1.1)
Use Eq. (1.21) to calculate the value of for the following cases. Use decimal numbers with six signifi-
cant numbers (apply rounding at each step). In each case calculate also the true relative error. Use MAT
LAB with format long to calculate the true value of .
(a) Use the first four terms. (b) Use the first six terms. (c) Use the first eight terms.
Solution
(a) Using the first four terms and 6 significant figures,
fx() ex
=
fx() ex1xx2
2!
—-x3
3!
—-x4
4!
—-x5
5!
—-++++++==
e2
e2
e212–2
8
6
+ 1 1.33333– 0.33333===