Consider the following program:
int main()
{
float x=1.1;
while(x==1.1)
{
printf("%f\n",x);
x=x-0.1;
}
getch();
}
Here,condition within while loop is checked first,as it is TRUE(1.1==1.1) (It seems so)
The statments within while loop are executed.Hence,the loop must print 1.1
only once.But it gives nothing at output.Which Means that the condition within while loop is false.How?
So,are there any special standards for comparing floating point numbers?
Aucun commentaire:
Enregistrer un commentaire