C examples for complex.h:abs
function template
<complex> <complex.h>
Absolute value of complex
template<class T> T abs (const complex<T>& x);
Parameter | Description |
---|---|
x | Complex value. |
The absolute value of x.
#include <iostream> #include <complex> int main ()//from w w w . j av a 2s . com { std::complex<double> mycomplex (3.0,4.0); std::cout << "The absolute value of " << mycomplex << " is " << std::abs(mycomplex) << '\n'; return 0; }