improved support for export/import of 64 bits
This commit is contained in:
parent
832b2258c8
commit
0d5fff0f16
|
@ -1027,22 +1027,34 @@ Yap_gmp_exp_big_big(Term t1, Term t2)
|
||||||
|
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_gmp_big_from_64bits(YAP_LONG_LONG i)
|
Yap_gmp_big_from_64bits(int64_t i)
|
||||||
{
|
{
|
||||||
char s[64];
|
char s[65];
|
||||||
MP_INT new;
|
MP_INT new;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
snprintf(s,64,"%I64d", (long long int)i);
|
snprintf(s,64,"%I64d", (long long int)i);
|
||||||
#elif HAVE_SNPRINTF
|
#elif HAVE_SNPRINTF
|
||||||
snprintf(s, 64, "%lld", (long long int)i);
|
snprintf(s, 64, "%lld", (int64_t)i);
|
||||||
#else
|
#else
|
||||||
sprintf(s, "%lld", (long long int)i);
|
sprintf(s, "%lld", (int64_t)i);
|
||||||
#endif
|
#endif
|
||||||
mpz_init_set_str (&new, s, 10);
|
mpz_init_set_str (&new, s, 10);
|
||||||
return MkBigAndClose(&new);
|
return MkBigAndClose(&new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t
|
||||||
|
Yap_gmp_big_to_64bits(Term t)
|
||||||
|
{
|
||||||
|
MP_INT *b = Yap_BigIntOfTerm(t);
|
||||||
|
int64_t rc;
|
||||||
|
mpz_export( &rc, NULL, 0, sizeof(int64_t), 0, 0, b);
|
||||||
|
if ( mpz_sgn(b) < 0 ) {
|
||||||
|
rc = -rc;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_gmq_rdiv_int_int(Int i1, Int i2)
|
Yap_gmq_rdiv_int_int(Int i1, Int i2)
|
||||||
{
|
{
|
||||||
|
@ -1752,6 +1764,7 @@ Yap_term_to_existing_rat(Term t, MP_RAT *b)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue