Beispiel #1
0
Datei: rat.go Projekt: ncw/gmp
// SetFloat64 sets z to exactly f and returns z.
// If f is not finite, SetFloat returns nil.
func (z *Rat) SetFloat64(f float64) *Rat {
	if math.IsNaN(f) || math.IsInf(f, 0) {
		return nil
	}
	z.doinit()
	C.mpq_set_d(&z.i[0], C.double(f))
	return z
}
Beispiel #2
0
// SetDouble sets f = x and returns q.
func (q *Rat) SetDouble(x float64) *Rat {
	q.doinit()
	C.mpq_set_d(&q.i[0], C.double(x))
	return q
}