Can GNU-Prolog handle big integer?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can GNU-Prolog handle big integer?

Shuai Wang
Hello gnu-prolog users,

I am new to prolog and I just have a quick question..

So basically on my 32bit x64 Linux, It seems that in GNU-Prolog, integer has only 28bits, so code like below can't be compiled by gplc.

    X is 0xdeadbeef.

After a quick search, I still don't know how to use GNU-Prolog to handle big integer...

I might be able split a 32bit integer like 0xdeadbeef into two 16bit integers 0xdead and 0xbeef and concat when necessary, but is there any more convenient way to do this?


Best Regards,
Shuai



_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Can GNU-Prolog handle big integer?

Daniel Diaz-3
Hello,

You are right, GNU Prolog uses bounded integers, whose bounds depend on
the architecture (32/64 bits). You can know these limits with (e.g. on a
64 bits machine):

| ?- current_prolog_flag(min_integer,X).

X = -1152921504606846976

yes
| ?- current_prolog_flag(max_integer,X).

X = 1152921504606846975

yes

A workaround to store bigger integers is to spit them into 2 parts and
for instance use a Prolog structure to record them.

Daniel


Le 12/06/2014 21:20, Shuai Wang a écrit :

> Hello gnu-prolog users,
>
> I am new to prolog and I just have a quick question..
>
> So basically on my 32bit x64 Linux, It seems that in GNU-Prolog,
> integer has only 28bits, so code like below can't be compiled by gplc.
>
>     X is 0xdeadbeef.
>
> After a quick search, I still don't know how to use GNU-Prolog to
> handle big integer...
>
> I might be able split a 32bit integer like 0xdeadbeef into two 16bit
> integers 0xdead and 0xbeef and concat when necessary, but is there any
> more convenient way to do this?
>
>
> Best Regards,
> Shuai
>


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.


_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog