Question: Compile and run the program. Answer the following questions either in the comments at the top of the file or in a separate text file:
Compile and run the program. Answer the following questions either in the comments at the top of the file or in a separate text file: 1. Note that the for loop ends when the long and float values diverge. Explain why they diverge by answering the following:
a) What is the last value that they match.
b) What would be the next value.
c) Work out floating point bit pattern for the last and next values.
d) Using the parts above, explain why the values stop matching after a time.
PROGRAM
===================================================
/*Lab 3 - Part A * Put your name here * Write your * answers to Part A * questions here * */
#include
void lastInt() { float fi = 15000000.0; unsigned int i = 15000000; for(; fi < 1e32; fi+=1, i+=1) { printf("%u -> %f ", i, fi); if(i != (int) fi) { break; } } }
int main() { lastInt(); return 0; } ======================================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
