fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <bits/stdc++.h>
  5. //#include <conio.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. /*http://w...content-available-to-author-only...t.com/c++-faq/floating-point-arith.html*/
  11. inline bool isEqual(double x, double y)
  12. {
  13. const double epsilon = 1e-9 /* some small number such as 1e-5 */;
  14. return std::fabs(x - y) <= epsilon;// * std::abs(x);
  15. // see Knuth section 4.2.2 pages 217-218
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21. double x1,y1,slobodni1,x2,y2,slobodni2;
  22. float m, n;
  23.  
  24. cout<<isEqual(0,10);
  25. cout<<isEqual(10,10);
  26. cout<<isEqual(10,0);
  27. cout<<isEqual(0,0);
  28.  
  29. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
0101