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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -