0
Float and double comparison (==). Here f is float and 1.25 is double how they can be equal?
int main() { float f = 1.30; int i=5; while(i--) { f = f - 0.01; } if(1.25 == f) printf("True "); else printf("False"); return 0; } Answers 1. Infinite Loop 2. No Output 3. False 4. True
2 Respostas
+ 1
They don't equal. But there it is compared values not the types in c. In any calculation of instruction, the operands are first converted or upcasted to higher types , then calculation is evaluated.
So both double type values are compared but may or may not equal, because of fraction part differences..
0
The answer is True I don't know why. They should not be equal