Homework 2

advertisement
COMPUTER ORGANIZATION & ASM LANGUAGE
CS 200
HM
PSU
WINTER 2003
HW2
HomeWork 2, Number Conversion, 100 Points (12/28/2002)
Due Date:
Subject:
Wednesday January 15th 2003, at start of class
Convert Numbers
General Rules: Do not write your homework in long hand. Instead, use a text editor, word-processor,
or similar tool and print your submission. However, if you use figures and graphics, they may be handdrawn; it is preferred, however, to generate them in electronic form as well, using Visio or similar.
1. (5) Convert the decimal number 99,99910 to an unsigned binary number.
2. (5) Convert the decimal number 99,99910 to an unsigned ternary number -- a number of base 3.
3. (5) Convert decimal 99,99910 to an unsigned hexadecimal number -- a number with base 16.
4. (5) Convert decimal 99,99910 to an unsigned number with base 20. The 20 digits are shown
below:
Value10
Digit20
0
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10 11 12 13 14 15 16 17 18 19
a b c d e f g h i j
5. (5) Explain overflow on an architecture that uses two’s complement binary numbers. Assume that
the sign bit is in the leftmost (most significant) binary position. State how many bits total are used.
6. (5) Add the binary numbers a and b and place the result in sum. What are the values of a, b, and
sum in decimal notation? Note that architecture for this assignment uses 8-bit signed binary numbers,
with two’s complement representation (tcr).
Operand
S
Binary Digits (Bits)
a
b
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
sum
1
1
1
1
1
1
1
1
7. (5) Convert the decimal numbers in the table below into their respective hexadecimal equivalent.
Note that it may help (to minimize work) to consult the on-line Lecture Notes.
Decimal
Hexadecimal
800
16,383
32,769
65,536
4,294,967,294
Winter 2003
1
HW 2
CS 200
HM
COMPUTER ORGANIZATION & ASM LANGUAGE
HW2
PSU
WINTER 2003
8. (5) Add all of the following 4 hexadecimal (hex) numbers. The prefix 0x is meant as an indicator a
hex number. It has no numeric value! Also, the underscore _ is meant to visually separate groups of 4
hex digits. It also has no numeric value.
0x2000_aaaa, 0x0009_9999, 0x0123_4567, 0xfedc_ba98
9. (5) What is the sum of the hexadecimal numbers above, expressed as a decimal number?
10. (5) represent the decimal value 12,345,67810 as a 32-bit, signed, binary number using tcr.
11. (5) Convert the following 32-bit, signed binary number to decimal. Underscores are used as visual
separators and have no numeric value. 0000_0000_0000_0011_0011_0011_1111_11112
12. (5) Convert the 32-bit, signed binary tcr number to decimal. Underscores are used as visual
separators and have no numeric value. 1111_1111_1111_1100_1100_1100_0000_00012
13. (5) Convert the 32-bit, signed binary tcr number to decimal. Underscores are used as visual
separators and have no numeric value. 1111_1111_1111_1111_1111_1111_1111_11112
14 (5). Convert decimal 123,45610 to a 32-bit, signed, two’s complement, binary number.
15 (5). Convert decimal 32,76710 to a 16-bit, signed, two’s complement, binary number.
16 (5). Convert decimal –32,76710 to a 16-bit, signed, binary number.
17 (5). Convert decimal –32,76810 to a 16-bit, signed, binary number.
18 (5). Add the following hexadecimal numbers. What is the decimal value of the resulting sum? (Note
that explicit bases are not shown as suffixes in the next few assignments, to emphasize the possible
ambiguity and misinterpretation of numbers.)
1234, 4321, 4444, 3333
19 (5). Add the following decimal numbers. What is the value of the resulting sum expressed as a
binary number?
1234, 4321, 4444, 3333
20 (5). Add the following base-5 numbers. What is the decimal value of the resulting sum?
1234, 4321, 4444, 3333
Winter 2003
2
HW 2
Download