i have read that some machine can’t express exaclty floating point number for example 1.1
let’s take code
float x=0.1;
do{
x+=0.1;
printf("%f\n",x);
} while(x!=1.1);
this code never finished how can i make that code finish? maybe convert it to double or?
In this case, checking “<” will do the trick:
In general, you should test against an “epsilon”. Look here for further information.