c - Why does this code print greater? -


this question has answer here:

1)#include<stdio.h> int main() { float x=0.5;  if(x>0.5) printf("\ngreater"); else printf("\nlesser "); return 0; } 

output->lesser

2)#include<stdio.h> int main() { float x=0.1;  if(x>0.1) printf("\ngreater "); else printf("\nlesser ");  return 0; } 

output->greater why in first case output "lesser" while in second 1 output "greater"? difference?

edit: understood 0.1 not equal, why 0.5 showing equal?

i sure it's because comparing float , double.

there's answer why greater answered here : 0.1 float greater double


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -