fix gmp calls

This commit is contained in:
Vitor Santos Costa 2016-05-13 11:43:01 +01:00
parent 428a6255e1
commit 3a9ecf929e
2 changed files with 27 additions and 2 deletions

View File

@ -1234,6 +1234,19 @@ Yap_gmp_cmp_big_int(Term t, Int i)
}
}
int
Yap_gmp_cmp_int_big(Int i, Term t)
{
CELL *pt = RepAppl(t);
if (pt[1] == BIG_INT) {
MP_INT *b = Yap_BigIntOfTerm(t);
return -mpz_cmp_si(b,i);
} else {
MP_RAT *b = Yap_BigRatOfTerm(t);
return -mpq_cmp_si(b,i,1);
}
}
int
Yap_gmp_cmp_big_float(Term t, Float d)
{
@ -1304,6 +1317,18 @@ Yap_gmp_tcmp_big_int(Term t, Int i)
}
}
int
Yap_gmp_tcmp_int_big(Int i, Term t)
{
CELL *pt = RepAppl(t);
if (pt[1] == BIG_INT) {
MP_INT *b = Yap_BigIntOfTerm(t);
return -mpz_cmp_si(b,i);
} else {
return 1;
}
}
int
Yap_gmp_tcmp_big_float(Term t, Float d)
{

View File

@ -538,13 +538,13 @@ Term Yap_gmp_fdiv_float_big(Float, Term);
Term Yap_gmp_fdiv_big_float(Term, Float);
int Yap_gmp_cmp_big_int(Term, Int);
#define Yap_gmp_cmp_int_big(I, T) (-Yap_gmp_cmp_big_int(T, I))
int Yap_gmp_cmp_int_big(Int, Term);
int Yap_gmp_cmp_big_float(Term, Float);
#define Yap_gmp_cmp_float_big(D, T) (-Yap_gmp_cmp_big_float(T, D))
int Yap_gmp_cmp_big_big(Term, Term);
int Yap_gmp_tcmp_big_int(Term, Int);
#define Yap_gmp_tcmp_int_big(I, T) (-Yap_gmp_tcmp_big_int(T, I))
int Yap_gmp_tcmp_int_big(Int, Term);
int Yap_gmp_tcmp_big_float(Term, Float);
#define Yap_gmp_tcmp_float_big(D, T) (-Yap_gmp_tcmp_big_float(T, D))
int Yap_gmp_tcmp_big_big(Term, Term);