// Num returns the numerator of z; it may be <= 0. The result is a // copy of z's numerator; it won't change if a new value is assigned // to z, and vice versa. The sign of the numerator corresponds to the // sign of z. // // NB In math/big this is a reference to the numerator not a copy func (z *Rat) Num() *Int { // Return an initialised *Int so we don't initialize or finalize it by accident z.doinit() res := new(Int) res.doinit() C.mpq_get_num(&res.i[0], &z.i[0]) return res }
// Num returns the numerator of x; it may be <= 0. The result is a // copy of x's numerator; it won't change if a new value is assigned // to x, and vice versa. The sign of the numerator corresponds to the // sign of x. // // NB In math/big this is a reference to the numerator not a copy func (x *Rat) Num() *Int { // Return an initialised *Int so we don't initialize or finalize it by accident x.doinit() z := new(Int) z.doinit() C.mpq_get_num(&z.i[0], &x.i[0]) return z }
func (q *Rat) Num(n *Int) *Int { q.doinit() n.doinit() C.mpq_get_num(&n.i[0], &q.i[0]) return n }