[m-users.] Too Slow
matthias.guedemann at googlemail.com
Tue May 12 03:19:46 AEST 2015
thanks for your comments. I have now simplified the C code as you
> To avoid truncation, you might have to use the mp_*_long_long
> functions. You can check long long is at least as wide as MR_Integer,
> at compile-time, with:
> :- pragma foreign_code("C", " MR_STATIC_ASSERT(mp_int, sizeof(unsigned
> long long) >= sizeof(MR_Integer)); ").
ok, I use mp_get_long_long now
> mp_init/4 contains a mp_set_int call.
> There is a problem with:
> abs(min_int) will overflow silently or crash the program.
ok, I chose the lazy solution to convert to string and then use
from_string to get the correct value. But isn't this a problem in int.m,
| abs(Num, Abs) :-
| ( Num < 0 ->
| Abs = 0 - Num
| Abs = Num
This results in 0 for min_int.
More information about the users