Search code examples
c++numbersnumber-formatting

C++ complex numbers, what is the right format?


I want to use C++ with complex numbers. Therefore I included #include <complex>. Now my question is: How do I declare a variable?(so what is the format called for let's say: 1 + i?)

Thanks in advance :-)


Solution

  • // 1 + 2i
    std::complex<double> c(1, 2);