CompOrg Fall 2003 Homework #1 FAQ


Homework #1 FAQ

Question: For the last 2 questions, can we use comparison operators ( < > ==, etc.) ?
Answer:

No. Only bitwise logic and boolean logic operators!

   
Question: What is to stop someone from using hex/binary calculator to do part of question 1?
Answer:

Nothing. But you won't be allowed to use a calculator on the test.

   
Question: Do I need to use Unix for the C programs?
Answer:

There are no C programs required! Problem 2 asks for C expressions, Problem 3 can be solved with a single expression, although you can also provide a little C code logic as well (for example, a few if statements).

It may certainly be useful to actually write programs to test your code! You can do this with any C compiler on any machine. The code required for both problems could be tested in a C++ program as well. Don't give us the entire program, we just want the expressions that answer the questions.

   
Question: The bias representation of the exponent in IEEE floating point numbers is confusing - I can't do the homework!

Answer:

Keep in mind the difference between a representation and a value. Given an IEEE floating point number (you are given the bits that make up the representation), you need to come up with a value for the exponent. To determine the value of the exponent you do the following:

  1. Take the 8 bits that represent the exponent and treat those 8 bits as an unsigned, 8-bit integer. You come up with a value in the range 0 to 255 (inclusive).

  2. Take the value from step 1 and subtract 127 (127 is the bias for 32-bit IEEE format). You now have a value in the range -127 to 128 (inclusive). This value is the exponent.

What if you know the value of the exponent and want to come up with the bit pattern that is used to represent that value in an IEEE 32-bit floating point number? Do this:

  1. The exponent value must be between -127 and 128 (inclusive), otherwise it is not possible to represent it using the format for IEEE 32 bit floating point numbers.

  2. Assuming the value is in the range described in step 1, add 127 (the bias) to this value and the new value will be in the range 0 to 255 (inclusive).

  3. Determine the 8-bit unsigned representation for the result of step 2 and this is the representation of the exponent.

Exponent Value Binary Representation Value of representation
as unsigned 8 bit
-12710
00000000
010
-12610
00000001
110
.
.
.
-110
01111110
12610
010
01111111
12710
110
10000000
12810
.
.
.
12810
11111111
25510