Standard library / math/cmplx
cmplx.Abs()
Magnitude of complex value, computed from both components. Expected stdout: '5\n'.
Formal Syntax & Structure
go syntaxgo
func Abs(x complex128) float64Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | complex128 | First input operand (or sole input if unary). |
Return Value
float64
Magnitude of complex value, computed from both components.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/cmplx")
func main() { fmt.Println(cmplx.Abs(3 + 4i))}