I am coding a simple DFT algorithm now and I want to use the complex number i in complex exponential. I saw somebody use #include
and #include&
pi, being an irrational number, cannot be exactly represented by a double. cos of an inexact approximation of pi is likely to yield a result which is close to but perhaps not exactly 1. Likewise sin of an inexact approximation of an inexact approximation of pi is like to result in a number is has a very small magnitude that is perhaps not exactly 0. Why not just define I to be std::complex(0.0, 1.0) and avoid the gratuitous inexactness.