Beispiel #1
0
func (r *Rational) Nearest(rs []*Rational) *Rational {
	var nearest *Rational
	for _, r2 := range rs {
		if nearest == nil {
			nearest = r2
		} else {
			res := C.av_nearer_q(r.CAVRational, r2.CAVRational, nearest.CAVRational)
			if res > 0 {
				nearest = r2
			}
		}
	}
	return nearest
}
Beispiel #2
0
func (r *Rational) Nearer(r2 *Rational, r3 *Rational) int {
	return int(C.av_nearer_q(r.CAVRational, r2.CAVRational, r3.CAVRational))
}