================================================================= Assignment #06 - Floating Point Numbers II & Character Encoding ================================================================= - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Available online: Tuesday March 2, 2010 Upload due date in the Blackboard Assignment Area: Upload "assignment06.txt" before 13:00 (1 pm) on Tuesday March 9, 2010. 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_06 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, if appropriate. Answers without methods are worth zero. 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. What is floating-point underflow? 2. Give an example of a number that would cause floating-point underflow if you tried to calculate it or represent it using IEEE-754 single-precision floating-point. 3. Why must you never test floating-point numbers for equality, i.e. why is "if ( a == b )" a bad idea for floating point a and b? 4. What is the correct way to test for floating-point "equality"? (Ch 2 Slide 84) 5. Write a tiny program fragment that uses a floating point loop that starts at 0.0, adds 0.01 each time through the loop, and stops when the loop counter is within 1.0e-10 ("epsilon") of the floating-point value 1000.1. Give the code for the loop here: 6. Find a hexadecimal table of EBCDIC letters and note the many "gaps" in the sequential order of the letters. Between what letters do the gaps in numbering occur in EBCDIC? (In other words, which letters differ by more than 1, such that you can't add one to a letter to get the next letter?) Write down all the gaps in both letter and hexadecimal form: 7. Find a hexadecimal table of ASCII characters and translate this string of hexadecimal bytes into ASCII characters: 4C 69 6E 75 78 20 52 6F 63 6B 73 5C 21 0D 0A 8. In EBCDIC, which comes first (i.e. has lower hex values): upper-case letters or lower-case letters? 9. In ASCII, which comes first (i.e. has lower hex values): upper-case letters or lower-case letters? 10. What *printable* characters do EBCDIC and ASCII have in common (if any)? That is, if you sent an EBCDIC file consisting of letters and spaces to an ASCII printer, what printable character(s) would you see on the ASCII printer? 11. There is only one bit of difference between an upper-case EBCDIC character and its lower-case equivalent. What is the hexadecimal and decimal value of this bit? What EBCDIC character does this bit value represent? 12. There is only one bit of difference between an upper-case ASCII character and its lower-case equivalent. What is the hexadecimal and decimal value of this bit? What ASCII character does this bit value represent? 13. What ASCII characters result from the following ASCII arithmetic (characters in single quotes are ASCII characters): a) 'A' + 1 = ____ b) 'Z' - 1 = ____ c) 'A' + ' ' = ____ d) 'z' - 'Z' = ____ e) '9' - '0' = ____ (this one is not an ASCII result!) NOTE: The ASCII character for a zero '0' does not have hexadecimal value zero! Check your ASCII table! 14. How do the ASCII character set and the Unicode character set relate to each other? 15. What is the default character set used in the Java language? 16. Without decoding using any ASCII table, explain why the following sequence of hexadecimal bytes is or is not likely to be from an ASCII text file: 84 03 fd ff ff c7 44 24 08 05 00 00 00 31 f6 c7 17. You look into memory and see the hexadecimal value 40h. Based on what you know in this course so far, what different things might this 40h represent? -- | 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/