示例#1
0
文件: rat.go 项目: ncw/gmp
// SetNum sets the numerator of z returning z
//
// NB this isn't part of math/big which uses Num().Set() for this
// purpose. In gmp Num() returns a copy hence the need for a SetNum()
// method.
func (z *Rat) SetNum(a *Int) *Rat {
	z.doinit()
	a.doinit()
	C.mpq_set_num(&z.i[0], &a.i[0])
	C.mpq_canonicalize(&z.i[0])
	return z
}
示例#2
0
文件: rat.go 项目: ncw/gmp
// SetFrac sets z to a/b and returns z.
func (z *Rat) SetFrac(a, b *Int) *Rat {
	z.doinit()
	a.doinit()
	b.doinit()
	// FIXME copying? or referencing?
	C.mpq_set_num(&z.i[0], &a.i[0])
	C.mpq_set_den(&z.i[0], &b.i[0])
	C.mpq_canonicalize(&z.i[0])
	return z
}
示例#3
0
文件: gogmp.go 项目: i-neda/gogmp
func (q *Rat) SetNum(n *Int) *Rat {
	q.doinit()
	n.doinit()
	C.mpq_set_num(&q.i[0], &n.i[0])
	return q
}