fork download
  1. #include <complex>
  2. #include <iostream>
  3. #include <cmath>
  4. #include <cfloat>
  5. using namespace std;
  6.  
  7. int main() {
  8. std::complex<double> number = std::exp(std::complex<double>(0, M_PI));
  9. std::cout << "DBL_EPSILON: " << DBL_EPSILON << std::endl;
  10. std::cout << "Number: " << number << std::endl;
  11. std::cout << "Is imaginary zero or close to it? " << std::boolalpha << (std::abs(number.imag()) < DBL_EPSILON) << std::endl;
  12. // your code goes here
  13. return 0;
  14. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
DBL_EPSILON: 2.22045e-16
Number: (-1,1.22465e-16)
Is imaginary zero or close to it? true