Standard library / math/big

big.Rat.Add()

Adds exact rational values into receiver. Expected stdout: '1/2\n'.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
x*RatFirst input operand (or sole input if unary).
y*RatSecond input operand.

Return Value

*Rat

Adds exact rational values into receiver.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(new(big.Rat).Add(big.NewRat(1, 3), big.NewRat(1, 6)))}
Go Reference