In C, 0.55 == 0.55f is false while 0.5 == 0.5f is true. Why is it different?
Comparing
0.55:#include <stdio.h> int main() { if (0.55 == 0.55f) printf("Hi"); else printf("Hello"); }Outputs
Hello.Comparing
0.5:#include <stdio.h> int main() { if (0.5 == 0.5f) printf("Hi"); else printf("Hello"); }Outputs
Hi.
For both the code snippets, I expected Hello.
Why this difference?