+ 5
Why can’t you not module doubles?
I tryed to do it here: But it shown a error? https://code.sololearn.com/c1CWFHDOSfte/?ref=app
4 odpowiedzi
+ 13
Modulus operator % is for integers.
You want fmod.
https://en.cppreference.com/w/cpp/numeric/math/fmod
+ 8
Thanks jay !
+ 4
#include <iostream>
#include<cmath>
using namespace std;
int main() {
double m = 2.00;
double m1 = 3.00;
double sum = fmod(m,m1);
cout<<sum<<endl;
return 0;
}
/*
thanks to Jay
*/
+ 2
and even using fmod, the answer will never be exact if it is not used with integer types.