# std::abs(std::complex)

< cpp‎ | numeric‎ | complex

C++
 Language Standard library headers Concepts Utilities library Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11)

Numerics library
 Common mathematical functions Floating-point environment Complex numbers Numeric arrays Pseudo-random number generation Compile-time rational arithmetic (C++11) Generic numeric operations iota (C++11) accumulate inner_product adjacent_difference partial_sum

std::complex
Member functions
Non-member functions
 real imag abs arg norm conj proj (C++11) polar operator""ioperator""ifoperator""il (C++14)(C++14)(C++14)
Exponential functions
Power functions
Trigonometric functions
 asin (C++11) acos (C++11) atan (C++11)
Hyperbolic functions
 asinh (C++11) acosh (C++11) atanh (C++11)

 Defined in header `` template< class T > T abs( const complex& z );

Returns the magnitude of the complex number `z`.

## Contents

### Parameters

 z - complex value

### Return value

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

Errors and special cases are handled as if the function is implemented as std::hypot(std::real(z), std::imag(z))

### Examples

```#include <iostream>
#include <complex>

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

Output:

`(1,1) cartesian is rho = 1.41421 theta = 0.785398 polar`