fork(3) download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <limits>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. double h = .1;
  9. double x = 1;
  10. int nSteps = abs(x / h);
  11.  
  12. double rem = fmod(x, h);
  13. cout<<"fmod output is "<<rem<<endl;
  14. if(abs(rem)<std::numeric_limits<double>::epsilon())
  15. cout<<"fmod output is almost near 0"<<endl;
  16.  
  17. rem = remainder(x,h);
  18. cout<<"remainder output is "<<rem<<endl;
  19. if(abs(rem)<std::numeric_limits<double>::epsilon())
  20. cout<<"remainder output is almost near 0"<<endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
fmod output is 0.1
remainder output is -5.55112e-17
remainder output is almost near 0