I have the following code
Case 1
float a=1.7; if(a==1.7) { printf("Equal\n"); } else if(a<1.7) { printf("less\n"); } else{ printf("Greater\n"); } Output
Greater Case 2
float a=1.3; if(a==1.3) { printf("Equal\n"); } else if(a<1.3) { printf("less\n"); } else{ printf("Greater\n"); } Output
Less Why the outputs are not as expected?
Why the outputs are different in both cases?
Can anyone explain how the values are stored and compared here
Thanks in advance
ais afloatand 1.7 isdouble. Due to assignment to the nearest FP value, 1.7 tofloatand 1.7 todouble, they differ.