Standard library / math/big

big.Float.Add()

Adds operands, rounding to receiver precision and mode. If precision is zero it adopts the larger operand precision. Opposite infinities panic with ErrNaN. Expected stdout: '2\n'.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
x*FloatFirst input operand (or sole input if unary).
y*FloatSecond input operand.

Return Value

*Float

Adds operands, rounding to receiver precision and mode. If precision is zero it adopts the larger operand precision. Opposite infinities panic with ErrNaN.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(new(big.Float).SetPrec(80).Add(big.NewFloat(1.25), big.NewFloat(0.75)))}
Go Reference