A RetroSearch Logo

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

Search Query:

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

public member function

<complex>

std::complex::imag get (1)
T imag() const;
set (2)
void imag (T val);

Imaginary part

Returns the imaginary part of the complex number.

Returns the imaginary part of the complex number (1), or sets val as the new value for the imaginary part (2).


The imaginary part is the factor by which the imaginary unit (i) is multiplied.

A non-member function exists with the same name: imag.



Parameters none

Return value The imaginary part.
T is complex's template parameter.

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

int main ()
{
  std::complex<double> mycomplex (20.0,2.0);

  std::cout << "Imaginary part: " << mycomplex.imag() << '\n';

  return 0;
}

Output:


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

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