std::abs(std::complex)

Header: <complex>

Returns the magnitude of the complex number z.

# Declarations

template< class T >
T abs( const complex<T>& z );

# Parameters

# Return value

If no errors occur, returns the absolute value (also known as norm, modulus, or magnitude) of z.

# Example

#include <complex>
#include <iostream>
 
int main()
{
    std::complex<double> z(1, 1);
    std::cout << z << " cartesian is rho = " << std::abs(z)
              << " theta = " << std::arg(z) << " polar\n";
}

# See also