The answers are supposed to be all zero.Code:cout << fmod(6.0*0.02, 0.02) << endl; cout << fmod(6*0.02, 0.02) << endl; cout << fmod(5.0*0.02,0.02) << endl; cout << fmod(5*0.02,0.02) << endl; cout << fmod(3.0*0.02,0.02) << endl; cout << fmod(3*0.02,0.02) << endl; (output) 0.02 0.02 3.46945e-018 3.46945e-018 0.02 0.02
I'm not sure why fmod() shows incorrect results for every multiple of 3 (3, 6, 9, ...)?
Does anyone have any idea?
Thanks.