Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (anonymous):
what should be the o/p of this code and why?
thnks in advance.
OpenStudy (anonymous):
Hi, try to use the debugger to see the actual values in memory see the Attach file (an image from my debugger VC++)
You can see that the actual value for f2 is: 14.3850002
OpenStudy (anonymous):
try to use: f to compare with the exact precision ok see this code:
#include<stdio.h>
#include<float.h>
using namespace std;
int main() {
float f1 = 14.375;
float f2 = 14.385;
if(f1 == 14.375f)
printf("YES\n");
else
printf("NO\n");
if(f2 == 14.385f)
printf("YES\n");
else
printf("NO\n");
return 0;
}