My solutions to the homework exercises appear in these
boxes below the problem. A couple notes:
Enjoy... yow, bill |
1. Convert the following binary numbers to octal, hex, and decimal:
To binary to octal, starting from the point and
heading left, group each three bits into one octal number. If the number
contains a fractional part (bits to the right of the point), then start at
the point head right and group 3 bits into an octal number.
Converting binary to hex, is a similar procedure except that bits are grouped 4 at a time, rather than 3. Converting binary to decimal, sum the value of each bit position whose value is 1. Don't forget that you can check your work by converting your octal and hex answers to decimal and checking them against the binary conversion. |
a) 1001
Octal: 11
Hex: 9
Decimal: 9
b) 1001 1010
Octal: 232
Hex: 9A
Decimal: 154
c) 1000 1011.011
Octal: 213.3
Hex: 8B.6
Decimal: 139.375
2. Convert the following decimal numbers to binary, octal and hex:
To convert decimal to binary, find the largest power of 2
that fits into the decimal number, subtract that amount, and then continue
with the bits to the right. You should also be able to use the
"halving method" described in class. This is particularly useful
for large numbers.
To convert to octal or hex, you can use the same procedure described for binary by finding the largest power of 8/16 and so on. A potentially easier approach is to convert to binary first, then do the binary to oct/hex conversion described above. |
a) 43
Binary: 10 1011
Octal: 53
Hex: 2B
b) 2005
Binary: 111 1101 0101
Octal: 3725
Hex: 7D5
3. Express the decimal number -2005 in each binary format:
a) signed magnitude
In signed-magnitude representation, a 1 in the first bit turns the following binary number to negative. SM: 1111 1101 0101
b) 1's complement
In 1's complement, the first (sign) bit is equal to -2^n + 1. Negating a positive binary number is accomplished by switching each bit. 1's comp: 1000 0010 1010
c) 2's complement
In 2's complement, the first (sign) bit is equal to -2^n. Negating a positive binary number is accomplished by switching each bit and then adding 1. 2's comp: 1000 0010 1011
d) Excess 2048
In excess representation, the number is stored as the binary value + 2^(m-1), where m is the number of bits. So, for example, -2005 would be represented as -2005 + 2048 = 43 in binary. Also, our text points out a shortcut that signed-magnitude is identical to 2's complement with the sign bit reversed.
Excess: 0000 0010 1011
4. Complete problem 6 on page 689
We didn't do this in class. Use each phalange (finger or toe) to
represent one bit. Doing this you can:
In doing 2's complement, let's start smaller. Using one hand with your thumb as the sign bit, then the largest negative number you can represent is your thumb up (or 1) followed by four 0's. In 2's complement, the sign bit is equal to -2^(n-1), so that's -2^4 or -16. The largest positive quantity is thumb 0 followed by four 1's, equaling 15. Extending this to all your fingers and toes:
|
5. Complete problem 7 on page 689
Remember, you get negate a number in 2's complement by flipping each bit and adding one. When adding 2's complement, we throw away any leftover carry bit, if one exists. | |||||||||||||||||||||
a.
|
b.
(note: this is actually an overflow for a 8-bit quantity) |
||||||||||||||||||||
c.
|
d.
|
6. Complete problem 8 on page 689
You negate a number in 1's complement by flipping each bit. If a carry occurs, then wrap-around and add it to the final result. Also, notice that adding positive quantities is the same in 2's complement and 1's complement. | |||||||||||||||||||||
a. Same as #5a above
|
b. Same as #5b above
|
||||||||||||||||||||
c.
|
d.
(Note: this is "negative zero", and a quantity with all 0's would be a "positive zero") |
7. Complete problem 14 on page 690
Binary multiplication is just like decimal multiplication:
Check it in decimal: 7 * 3 = 21. Yup. |
... Appendix B questions below...
8. Complete problem 1 on page 698
The single precision format is
S (1 sign bit), E (8 exponent bits), F (23 fraction bits) which is assigned a value of value = (-1)^S + (1 + F) * 2^(E - 127) The exponent is represented in biased by 127, hence the subtraction. The fraction is normalized with a 1 assumed before the point. |
||||||||
a. 9
Convert to a normalized binary number:
Giving:
|
||||||||
b. 5/32
Convert:
Giving:
|
||||||||
c. -5/32
Just flip the sign bit of the answer above:
|
||||||||
d. 6.125
Convert:
Go:
|
9. Complete problem 2 on page 698, convert to binary or hex value rather than decimal to save some time.
a. 42E4 8000
Expand to binary:
|
||||||||||||
b. 3F88 0000
Go:
|
||||||||||||
c. 0080 0000
Go:
|
||||||||||||
d. C7F0 0000
Go:
|