Example #1
0
File: rat.go Project: ncw/gmp
// Denom returns the denominator of z; it is always > 0.  The result
// is a copy of z's denominator; it won't change if a new value is
// assigned to z, and vice versa.
//
// NB In math/big this is a reference to the denominator not a copy
func (z *Rat) Denom() *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_den(&res.i[0], &z.i[0])
	return res
}
Example #2
0
File: rat.go Project: locusf/gmp
// Denom returns the denominator of x; it is always > 0.  The result
// is a copy of x's denominator; it won't change if a new value is
// assigned to x, and vice versa.
//
// NB In math/big this is a reference to the denominator not a copy
func (x *Rat) Denom() *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_den(&z.i[0], &x.i[0])
	return z
}
Example #3
0
func (q *Rat) Den(n *Int) *Int {
	q.doinit()
	n.doinit()
	C.mpq_get_den(&n.i[0], &q.i[0])
	return n
}