Standard library / math/big
big.Int.Int64()
Convert to int64 only when representable; otherwise the result is undefined. Check IsInt64 first. Expected stdout: '-42\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Int) Int64() int64Return Value
int64
Returns the result described above; see the example for the observed behavior.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/big")
func main() { x := big.NewInt(-42) if x.IsInt64() { fmt.Println(x.Int64()) }}