Step 0

  • Start a new CCS project nemed Part1
  • Write the slightly less simple C program shown here.
  • Start the debugger
  • Step to line 6 so that all variables have been initialized.

Step 1

  • Use this calculator and write down what the hex should be for each float
  • For each variable, go look at it in memory and verify that it is correct

Step 2

  • Continue to step through the program
  • Watch how the variables change as you step
  • Convince yourself how a for loop works

Step 3

  • After a few iterations, right click on the variable sum and change the number format to hex (this will keep us from having to go back and forth to the memory view)
  • Continue to step until sum stops changing.
  • Record the value of n
  • Record the hex and decimal values for sum.
  • What did we calculate?

Step 4

  • Write down the proper equation for what sum is representing here (either interpret the code or look it up)
  • Look at the value of this number to 50 decimal places on Wikipedia and compare
  • Write down the exponent bits
  • Write down the first 4 fraction bits
  • Convert these two to a human-readable, scientific-notation-like format

Step 5

  • Why did sum stop changing even though there were more iterations? What was limiting us?
  • Is it possible to do better on this machine? Write down some idea on how it could be done if it is possible
  • Flag down a Labbie!

Review

  • Additional iterations does not equal additional precision
  • Understanding data types can help you realize this and write better code

Good Job!

I hope you thought that was fun, because you're not done yet! One more part left!!