=================================================
Assignment #05 - Number Systems with Floating Point Numbers
=================================================
- Ian! D. Allen - idallen@idallen.ca - www.idallen.com
Available online: Tuesday February 9, 2010
Upload due date in the Blackboard Assignment Area:
Upload "assignment05.txt" before 13:00 (1 pm) on Tuesday February 23, 2010
(NOTE: February 16 falls during study break week - no classes.)
Do *not* use the DigitalDropbox to submit your answers.
Answers will be posted shortly after the due date/time.
Submission method: Upload via the "Assignments" CST8281_Assignment_05 upload.
Use the file name given above. Upload only one single file of plain
text, not HTML, not MSWord, not RTF. No fonts, no word-processing.
Plain text only. Did I mention that the format is plain text (Notepad)?
Due to bugs in Blackboard, you can only submit your Assignment to me *once*.
After that, you cannot submit any more times. If you need to re-submit
it, you have to email me to ask me to clear your previous submission.
Do *not* use EMail or the DigitalDropbox to submit your answers.
Answers will be posted after the due date/time so that you can check
your answers before coming to labs and ask questions about the answers
in the labs. Please check your answers (and my answers!). I go over
each assignment in the lab 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.
Not all assignments will be marked. See the Week 1 Notes for details.
==============================================================================
Edit this file and answer the following questions underneath each
question, showing how you obtained each answer. Answers without methods
are worth zero.
The point of the conversions is not to show me the answer. I already
give you many of the answers. The point is to show me that you have a
clear *method* for getting that answer that works for you. Show me a
clear method that must work for any number.
Upload the file containing the methods and the answers before the
due date. Some of the answers below may require reading the URL links
published in the weekly notes.
==============================================================================
1. Conversions from different bases and representations to decimal:
a) Given the digits 010101(16), convert to decimal from base "16" =
b) Given the digits 010101(10), convert to decimal from base "10" =
c) Given the digits 010101(8), convert to decimal from base "8" =
d) Given the digits 010101(2), convert to decimal from base "2" =
e) Given the digits 010101(-2), convert to decimal from base "-2" =
f) Given the digits 010101(2), convert to decimal from bias-127 =
g) Given the digits 010101(2), convert to decimal from bias-63 =
h) Given the digits 010101(2), convert to decimal from bias-31 =
i) Given the digits 010101(2), convert to decimal from bias-16 =
Reference: http://en.wikipedia.org/wiki/Signed_number_representations
2. Perform the following additions and subtractions in binary, assuming
a 6 bit word. Show the Result value plus the values of the Zero, Sign,
Carry, and Overflow flag values for each (five answers for each).
(The Zero flag is on iff the Result is zero.)
011010 011010
+ 001111 - 001111
ANSWERS:
010111 010110
+ 101001 - 010110
ANSWERS:
3. What is the minimum number of binary bits needed to represent the number
of each day in the year (the Julian day number)?
4. What is the minimum number of binary bits needed to represent the
number of each day in the year, if the number of days can be positive
or negative (e.g. "minus 300 days" or "today - 300")?
5. Unix/Linux has traditionally used a 32-bit signed integer to
store the number of seconds since midnight on January 1, 1970, UTC.
Calculate roughly in what year/month/day this value overflows and
time starts going negative.
6. 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.
a. -1 ANSWERS:
b. +693 ANSWERS:
c. -693 ANSWERS:
d. 2048 ANSWERS:
e. -2048 ANSWERS:
f. 4097 ANSWERS:
7. Perform the indicated arithmetic in hexadecimal, assuming a 12-bit word.
Show the hexadecimal result plus the states of the Zero, Sign, Carry
and Overflow flags (five answers for each problem).
D8A 948 C8B ACE
+276 -35A +839 -BDF
ANSWERS:
8. Express floating-point 123.456 as a normalized decimal number using
scientific notation with four digits of precision.
9. Add floating-point decimal 1234000.0 to 1.5 and express the result as
a normalized decimal number using scientific notation with four
digits of precision.
10. Add *binary* floating-point 1111000.0 to 1.1 and express the result
as a normalized binary number using (binary) scientific notation
with four (binary) digits of precision.
11. Looking at the two previous questions, is it possible in a computer
to add a number to a floating-point number without having any effect,
i.e. is it true that A+B=B for certain floating-point values of A and B?
12. Encode the decimal value +274.5625 as a 32-bit IEEE-754 floating
point field and show your final answer in hexadecimal.
13. Encode the decimal value -12.1875 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
14. Encode the decimal value +0.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
15. Encode the decimal value -0.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
16. Encode the decimal value +1.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
17. Encode the decimal value -1.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
18. Encode the decimal value +2.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
19. Encode the decimal value -2.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
20. Encode the decimal value +4.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
21. Encode the decimal value -4.0 as 32-bit IEEE-754 floating point
field and show your answer in hexadecimal.
22. Assuming the following eight-byte hex dump contains two Big-Endian,
32-bit, IEEE-754 encoded values: C2 2D C0 00 3F 60 00 00
decode both values shown in this dump as separate decimal values.
23. The IEEE 754 floating-point number 81234567h is negative. Without
converting, give the hexadecimal for the same number, only positive.
24. The IEEE 754 floating-point number 7EDCBA98h is positive. Without
converting, give the hexadecimal for the same number, only negative.
25. Without converting, cross out or delete all the IEEE 754 negative numbers,
leaving only the positive numbers:
1837A654h 7A6A3B65h 87B5CDE2h 90A5B5EFh A0000037h D1B8765Ah F0000000h
26. How does the answer to the previous question change if you are told that
all the bit patterns are really IEEE 754 double-precision numbers?
27. Which has more *Precision* available - a 32-bit integer or a 32-bit
floating-point number?
28. Which has more *Range* available, - a 32-bit integer or a 32-bit
floating-point number?
29. IEEE 754 single-precision floating-point can store numbers in the
approximate range of -2**127 to +2**+127. Look up or use a calculator
to express this range (approximately) as powers of ten (decimal).
30. True/False: Decimal 1234.0 x 10**37 fits in IEEE 754 single precision
floating point.
31. True/False: Decimal 0.00001 x 10**40 fits in IEEE 754 single
precision floating point.
32. Cross-out or delete the values that fit in IEEE 754 single precision
floating point with no loss of range or precision, leaving only the
values that do *not* fit completely accurately:
2**30-3 2**30-1 2**30 2**30+1 2**30+3 2**30+2**29
33. Without converting, cross-out or delete the sums that fit in IEEE 754
single-precision floating-point with no loss of range or precision,
leaving only the sums that do *not* fit accurately:
2**29+2**10+2**9+2**0 2**26+2**0 2**29+2**28+2**27+2**26
2**27+2**23+2**1 2**29+2**28+2**2+2**1
34. Why do the decimal numbers 2147483775 (0x8000007F) and 2147483648
(0x80000000) both convert to the same IEEE 754 single-precision
floating-point number 0x4F000000 that has decimal value 2147483648.0?
35. Explain why, in a computer, floating point mathematics may not be
associative or distributive, i.e. (A+B)+C may not equal A+(B+C).
36. How close to zero can you get with IEEE 754 32-bit floating point?
(What is the non-zero value that is closest to zero?) Express the
answer in both approximate power-of-two notation and in approximate
power-of-ten notation.
--
| 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/