Standard library / math/big

big.Int.SetString()

Parses integer with base 0 or 2 through 62; returns receiver and true on success, nil and false otherwise; receiver value then undefined. Expected stdout: '18446744073709551616 true\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) SetString(s string, base int) (*Int, bool)

Parameters & Attributes

NameTypeDescription
sstringInput text.
baseintNumeric radix.

Return Value

(*Int, bool)

Parses integer with base 0 or 2 through 62; returns receiver and true on success, nil and false otherwise; receiver value then undefined.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  v, ok := new(big.Int).SetString("18446744073709551616", 10)  fmt.Println(v, ok)}
Go Reference