=================================================
Assignment #04 - Integer Numeric Conversions
=================================================
- Ian! D. Allen - idallen@idallen.ca - www.idallen.com
Available online: Friday January 28, 2011
Upload due date:
Upload answer file before 23:59 (midnight) on Thursday February 3, 2011
Answers will be posted shortly after the due date/time and discussed
in class, if there are any questions about the answers.
Late assignments may or may not be marked.
Submission method:
Create a plain text file using the exact name "assignment04.txt"
Upload the file via the Assignment04 "Upload File" facility in Blackboard.
Use "Attach File" and "Submit" to upload your plain text file.
No wordprocessor documents. Do not send email. Use only "Attach File".
Use the file name given above. Upload only one single file of plain text,
not HTML, not MSWord. No fonts, no word-processing. Plain text only.
Did I mention that the format is plain text (VIM/Nano/Pico/Gedit or Notepad)?
NO WORD PROCESSOR DOCUMENTS ACCEPTED.
No marks are awarded for submitting under the wrong assignment number.
Not all assignments will be marked. See the Week 1 Notes for details.
Answers will be posted after the due date/time so that you can check
your answers before coming to class and ask questions about the answers
in class. Please check your answers (and my answers!). I go over
each assignment in class if there are questions about the answers.
No questions means no review - I'll presume you know the material.
Questions similar to ones on these assignments will appear on your tests
and exams.
DO THIS:
Edit this file and answer the following questions underneath each
question, showing the method or formula you used to get the answer.
Many of the questions already give you the answer - you must show
the full method you use to generate that answer. Upload the file
containing the question, methods, formulas, and answers before the
due date. Some of the answers below will require reading the links
published in the weekly course notes.
Full marks are awarded only if you show your method, the same method
you will have to use on your midterm test (no calculators).
==============================================================================
Full marks are awarded only if you show your method.
Take care to panic and do bit-flipping only for *negative* numbers.
1. Convert binary 11101101001111001001000000011010(2) to hexadecimal
(base 16) by using groups of four bits, starting from the right.
Hint: Your answer will have eight hex digits and the rightmost hex
digit will be "A": (See ECOA2e Chapter 2 slide 27 for the method.)
2. Convert binary 110011101010001100111000(2) to octal (base 8) by using
groups of three bits, starting from the right. Hint: Your answer
will have eight octal digits and the rightmost octal digit will be
"0": (See ECOA2e Chapter 2 slide 27 for the method.)
3. Write 11101110(2) in octal (base 8) and hexadecimal (base 16).
4. Write 00011011(2) in octal (base 8) and hexadecimal (base 16).
5. Write 11110101(2) in octal (base 8) and hexadecimal (base 16).
6. Write 10101001(2) as octal (base 8) and hexadecimal (base 16).
7. Write 10010010(2) as octal (base 8) and hexadecimal (base 16).
8. Convert 6253(8) octal to CAB(16) hexadecimal by regrouping binary bits.
9. Convert 8A9Dh (hexadecimal) to octal (base 8) by regrouping binary bits.
10. Convert ABCEh (hexadecimal) to octal (base 8) by regrouping binary bits.
11. Convert 8-bit 10010010(2) binary unsigned to 146(10) decimal.
(See ECOA2e Chapter 2 slide 8 for the method.)
12. Write 23(10) in octal. (See ECOA2e Chapter 2 slides 11-17 for two methods.)
13. Convert 16-bit unsigned hexadecimal 0x142B to 5,163(10) decimal.
14. Convert unsigned 16-bit 1AAC(16) to 6,828(10) decimal.
15. Convert 16-bit unsigned FFFFh to decimal 65,535 using a trick
to reduce the number of multiplications and additions.
16. Convert unsigned 16-bit 7FFE(16) to decimal 32,766(10).
Hint: Use a trick to cut down on the number of multiplies and adds.
17. Convert 16-bit unsigned 8001h to decimal 32,769.
18. Convert 16-bit unsigned A1A3h to decimal 41,379.
19. Convert binary fraction 0.1111(2) to 0.9375 decimal.
20. Convert 25(10) decimal to 11001(2) binary.
(See ECOA2e Chapter 2 slides 11-17 for two methods.)
21. Convert 39(10) to 27 hexadecimal.
(See ECOA2e Chapter 2 slides 11-17 for two methods.)
22. Convert 155(10) decimal to 10011011(2) binary.
23. Convert 0.75(10) to 0.11(2) binary (see ECOA2e Chapter 2 slide 19).
24. Convert 0.8125(10) to 0.1101(2) binary (see ECOA2e Chapter 2 slide 21).
25. Convert 0.34350(10) to 0.0101(2) binary, stopping at four fractional bits.
(This does not mean truncating 0.34350 to 0.3435. It means calculating
the binary fraction for 0.34350 and stopping when you have four binary
digits to the right of the binary radix point, as shown in the answer
above. The remaining bits are left uncalculated, and so the answer is
actually wrong - it doesn't add up. Computers are like that - sometimes
you don't have space for all the binary bits and the answer is wrong.)
(see ECOA2e Chapter 2 slides 18-24).
26. Assuming an 8-bit word, show using unsigned binary how such a word
would be encoded to represent the decimal number 86:
27. Convert decimal 2.5625 to binary.
28. Show that Christmas == Halloween by converting DEC 25 to OCT 31
(convert DECimal 25 into OCTal 31)
29. Convert 23 to 8-bit 00010111 binary one's complement.
30. Convert -23 to 8-bit 11101000 binary one's complement.
31. Convert 23 to 8-bit 00010111 binary two's complement.
32. Convert -23 to 8-bit 11101001 binary two's complement.
33. Convert -10 to 8-bit 11110101 binary one's complement.
34. Convert -10 to 8-bit 11110110 binary two's complement.
35. Convert 8-bit 10010011 binary sign-magnitude to -19 decimal (note
the negative).
36. Convert 8-bit 10010011 binary one's complement to -108 decimal (note
the negative).
37. Convert 8-bit 10010011 binary two's complement to -109 decimal (note
the negative).
38. Convert 16-bit two's complement 8000h to decimal -32,768 (note the
negative).
39. Convert 16-bit two's complement A123h to decimal -24,285 (note negative).
40. Convert 16-bit two's complement FFFFh to decimal -1 (note the negative).
41. Here are 16-bit two's complement numbers. Put minus signs in front
of all the negative numbers.
9000h A001h 7FC5h C123h B3FFh
42. Indicate using an "X" which of the following positive values will
*NOT* fit correctly in a 32-bit two's complement integer:
(2**29)-1 2**29 (2**29)+1
(2**30)-1 2**30 (2**30)+1
(2**31)-1 2**31 (2**31)+1
(2**32)-1 2**32 (2**32)+1
(2**33)-1 2**33 (2**33)+1
(2**30)+(2**29) (2**30)+(2**29)+(2**3)+(2**2)+(2**1)
If possible, convert the following decimal values into 2's complement
form, assuming a 12-bit word. Show your results in both binary
and hexadecimal.
43. -1 decimal to 12-bit two's complement binary and hex.
44. +693 decimal to 12-bit two's complement binary and hex.
45. -693 decimal to 12-bit two's complement binary and hex.
46. +2048 decimal to 12-bit two's complement binary and hex.
47. -2048 decimal to 12-bit two's complement binary and hex.
48. +4097 decimal to 12-bit two's complement binary and hex.
Full marks are awarded only if you show your method.
--
| Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada
| Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/