real - C complex.h

C examples for complex.h:real

type

function template

From


<complex>
<complex.h>

Prototype

template<class T> T real (const complex<T>& x);
double real (ArithmeticType x);  // additional overloads

Description

Returns the real part of the complex number x.

Parameters

Parameter Description
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).

Demo Code


#include <iostream> // std::cout
#include <complex> // std::complex, std::real

int main ()/*w  w w.jav a2  s. c  o  m*/
{
  std::complex<double> mycomplex (10.0,1.0);

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

  return 0;
}

Related Tutorials