fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double __rD(double d, int symAPt) { // round double
  6. symAPt = pow(10, symAPt);
  7. return static_cast<double>(static_cast<long long>(d * symAPt)) / symAPt;
  8. }
  9. bool equal(double a, double b, int pr) {
  10. bool r = (__rD(a, pr) == __rD(b, pr));
  11. return r;
  12. }
  13.  
  14. int main() {
  15. cout << equal(3.14, 3.14, 2);
  16. return 0;
  17. }
Success #stdin #stdout 0s 4356KB
stdin
Standard input is empty
stdout
1