Standard library / strconv
strconv.ParseComplex()
Parses a complex number such as 2+3i. bitSize 64 or 128 selects component precision; returns complex128 and error. Expected stdout: '(2-3i) <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func ParseComplex(s string, bitSize int) (complex128, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text to parse, inspect or quote. |
| bitSize | int | Total complex width, 64 or 128. |
Return Value
(complex128, error)
Decoded or parsed value and error; inspect the error before using the result.
Working Example
Example Snippetgo
package main
import ( "fmt" "strconv")
func main() { v, e := strconv.ParseComplex("2-3i", 128) fmt.Println(v, e)}