A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/complex/real/ below:

function template

<complex>

std::real complex (1)
template<class T> T real (const complex<T>& x);
complex (1)
template<class T> T real (const complex<T>& x);
arithmetic type (2)
double real (ArithmeticType x);  // additional overloads

Real part of complex

Returns the real part of the complex number x.

The function returns the same as if calling:

x.real()

.


The function returns the same as if calling:

x.real()

for

(1)

.

Additional overloads (2) are provided for arguments of any fundamental arithmetic type: In this case, the function assumes the value has a zero imaginary component, and thus simply returns x converted to the proper type.

The return type is

double

, except if the argument is

float

or

long double

(in which case, the return type is of the same type as the argument).



Parameters
x
Complex value.

Return value Real part of x.
T is the type of the components of the complex type (i.e., its value type).

Example
1
2
3
4
5
6
7
8
9
10
11
12
// std::real example
#include <iostream>     // std::cout
#include <complex>      // std::complex, std::real

int main ()
{
  std::complex<double> mycomplex (10.0,1.0);

  std::cout << "Real part: " << std::real(mycomplex) << '\n';

  return 0;
}

Output:


See also
imag
Imaginary part of complex (function template)
complex::real
Real part (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4