a := big.NewRat(3, 4) b := big.NewRat(5, 6) c := new(big.Rat).Mul(a, b) fmt.Println(c)
x := big.NewRat(2, 3) y := big.NewRat(4, 5) z := x.Mul(x, y) fmt.Println(z)Output: `8/15` This example uses the Mul method on the Rat value x directly, rather than creating a new Rat value to store the result. It multiplies x with the fraction 4/5, and the result is stored back into x. The final output is the simplified fraction 8/15, which is the product of 2/3 and 4/5. Package library: math/big