Built-in function

Go real()

Returns the real component of a complex value. The result is float32 for complex64, float64 for complex128, or an untyped floating-point constant for an untyped complex constant. Example prints 3.

Formal Syntax & Structure

go syntaxgo
real(z)

Parameters & Attributes

NameTypeDescription
zcomplex valueInput number.

Return Value

float32, float64 or untyped floating-point constant

Real part.

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  z := complex(3.0, -4.0)  fmt.Println(real(z))}
Go Reference