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) *RatParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | *Rat | First input operand (or sole input if unary). |
| y | *Rat | Second 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)))}