Return the imaginary part of a complex number.
The imag built-in function returns the imaginary part of the complex number c. The return value will be a floating point type corresponding to the type of c: float32 for complex64, and float64 for complex128.
imag is typically used alongside real() to decompose a complex number into its component parts.
| Name | Description | Optional |
|---|---|---|
c |
A complex number. | No |
c := complex(3.0, 4.0) // 3+4i
fmt.Println(imag(c)) // 4