I have a big loop using double numbers, and Im using fmod to print "*" when I have modulo equals zero:
for(double tp=0 ; tp<=1 ; tp=tp+0.01) {
for(double p=0 ; p<=1 ; p=p+0.01) {
tt=1+2*tp;
for(double t=0 ; t<1000 ; t+=0.01) {
printf(" t=%f (tt=%f) (%%=%f)|",t,tt,fmod(t,tt));
if(fmod(t,tt)==0.0) {
printf("*");
}
}
}
when I run this, I can see a lot of zeros in " (%%=%f) " - which prints the result of the fmod. but I cant find "*" !! menas the if statment returns false even the result euqals zero!!! why is that? thanks alot
Aucun commentaire:
Enregistrer un commentaire