Standard library / math/big

big.Rat.Num()

Return a pointer to the signed numerator, aliasing receiver storage. Copy it before modifying independently. Expected stdout: '-3 -3/4\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Rat) Num() *Int

Return Value

*Int

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  x := big.NewRat(-6, 8)  n := new(big.Int).Set(x.Num())  fmt.Println(n, x)}
Go Reference