Standard library / math/big

big.Int.Add()

Stores x+y in receiver; receiver may alias an operand. Expected stdout: '42\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) Add(x, y *Int) *Int

Parameters & Attributes

NameTypeDescription
x*IntFirst input operand (or sole input if unary).
y*IntSecond input operand.

Return Value

*Int

Stores x+y in receiver; receiver may alias an operand.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  x := big.NewInt(20)  fmt.Println(x.Add(x, big.NewInt(22)))}
Go Reference