+ 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

25th Oct 2018, 1:26 AM
Potato Hacker
Potato Hacker - avatar
4 ответов
+ 13
Modulus operator % is for integers. You want fmod. https://en.cppreference.com/w/cpp/numeric/math/fmod
25th Oct 2018, 2:02 AM
jay
jay - avatar
+ 8
Thanks jay !
25th Oct 2018, 2:03 AM
Potato Hacker
Potato Hacker - avatar
+ 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 */
25th Oct 2018, 8:01 AM
Md. Mehrajul Islam
Md. Mehrajul Islam - avatar
+ 2
and even using fmod, the answer will never be exact if it is not used with integer types.
25th Oct 2018, 2:42 PM
Bebida Roja
Bebida Roja - avatar