Exemplo n.º 1
0
Arquivo: rat.go Projeto: ncw/gmp
// Cmp compares z and y and returns:
//
//   -1 if z <  y
//    0 if z == y
//   +1 if z >  y
//
func (z *Rat) Cmp(y *Rat) (r int) {
	z.doinit()
	y.doinit()
	r = int(C.mpq_cmp(&z.i[0], &y.i[0]))
	if r < 0 {
		r = -1
	} else if r > 0 {
		r = 1
	}
	return
}
Exemplo n.º 2
0
// Cmp compares x and y and returns:
//
//   -1 if x <  y
//    0 if x == y
//   +1 if x >  y
//
func (x *Rat) Cmp(y *Rat) int {
	x.doinit()
	y.doinit()

	switch cmp := int(C.mpq_cmp(&x.i[0], &y.i[0])); {
	case cmp < 0:
		return -1
	case cmp == 0:
		return 0
	}
	return 1
}
Exemplo n.º 3
0
func CmpRat(x, y *Rat) int {
	x.doinit()
	y.doinit()
	return int(C.mpq_cmp(&x.i[0], &y.i[0]))
}