[Caml-list] convertion between OCaml Big_int and C

18 views
Skip to first unread message

Jianzhou Zhao

unread,
Oct 13, 2010, 10:26:52 AM10/13/10
to caml...@yquem.inria.fr
Hi All,

I am not sure if this is a reasonable question. Does OCaml already
have functions that do convertion between arbitrary-precision integers
big_int in OCaml and any representation of large intergers in C? The
implementation of big_int (otherlibs/num/big_int.*) uses nat
(otherlibs/num/nat.*). Nat is a customized allocation (in C) as a list
of native integers to represent arbitrary-precision. So converting
big_int into C seems possible to me.

Thanks.
--
Jianzhou

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Olivier Schwander

unread,
Oct 13, 2010, 11:07:36 AM10/13/10
to caml...@yquem.inria.fr
Le 13 Oct 2010 10:26, Jianzhou Zhao a �crit:

> I am not sure if this is a reasonable question. Does OCaml already
> have functions that do convertion between arbitrary-precision integers
> big_int in OCaml and any representation of large intergers in C? The
> implementation of big_int (otherlibs/num/big_int.*) uses nat
> (otherlibs/num/nat.*). Nat is a customized allocation (in C) as a list
> of native integers to represent arbitrary-precision. So converting
> big_int into C seems possible to me.

It seems you should have a look at the numerix library or at the OCaml
binding for GMP. I never used any of them so I cannot guaranty there are
really working (there are not a lot of references to them) but I think
they are more likely to be usable on both OCaml and C side.

Cheers,

Olivier

Jianzhou Zhao

unread,
Oct 13, 2010, 12:01:56 PM10/13/10
to Olivier Schwander, caml...@yquem.inria.fr
On Wed, Oct 13, 2010 at 10:48 AM, Olivier Schwander
<olivier....@chadok.info> wrote:
> Le 13 Oct 2010 10:26, Jianzhou Zhao a �crit:
>> I am not sure if this is a reasonable question. Does OCaml already
>> have functions that do convertion between arbitrary-precision integers
>> big_int in OCaml and any representation of large intergers in C? The
>> implementation of big_int (otherlibs/num/big_int.*) uses nat
>> (otherlibs/num/nat.*). Nat is a customized allocation (in C) as a list
>> of native integers to represent arbitrary-precision. So converting
>> big_int into C seems possible to me.
>
> It seems you should have a look at the numerix library or at the OCaml
> binding for GMP. I never used any of them so I cannot guaranty there are
> really working (there are not a lot of references to them) but I think
> they are more likely to be usable on both OCaml and C side.

Thanks. Are they the MLGMP and Numerix listed in "the Caml Hump:
General purpose libraries :: Numeric computation" ?
http://caml.inria.fr/cgi-bin/hump.en.cgi?sort=0&browse=75
>From the documents of Numerix, it runs much faster than the big_int
library, although it may not be as portable as the 'nat' that big_int
replies on.

>
> Cheers,
>
> Olivier
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

--
Jianzhou

Olivier Schwander

unread,
Oct 13, 2010, 1:03:55 PM10/13/10
to Jianzhou Zhao, caml...@yquem.inria.fr
Le 13 Oct 2010 12:01, Jianzhou Zhao a �crit:

> Thanks. Are they the MLGMP and Numerix listed in "the Caml Hump:
> General purpose libraries :: Numeric computation" ?
> http://caml.inria.fr/cgi-bin/hump.en.cgi?sort=0&browse=75
> From the documents of Numerix, it runs much faster than the big_int
> library, although it may not be as portable as the 'nat' that big_int
> replies on.

Yes, there is also mlgmpidl
<http://www.inrialpes.fr/pop-art/people/bjeannet/mlxxxidl-forge/mlgmpidl/>.

Reply all
Reply to author
Forward
0 new messages