Is there a Bignum module for Ocaml?

I did a little work and, apparently, the Bignum module was used in the standard library in accordance with this. But at the moment I can’t see anything in the standard library.

+4
source share
3 answers

Technically, the standard library does not have a bignum module, because the standard library in Ocaml terminology is the default library with which programs are compiled, and there is no bignum module there. There is also no Bignum library, because the bignum library is called nums , and its main module is called Num . It was part of the standard distribution of Ocaml, since before Ocaml was named Ocaml, it is still there.

+11
source

You are looking for the num library. Technically, this is not part of the Standard Library, but is part of the standard distribution. Thus, just compile this library and it will be available. You might also be interested in the new zarith library. I'm not sure how they compare.

+9
source

To add to the other answers, the general arbitrary precision module is Num (it includes large integers and large rational numbers). There is a separate Big_int module only for large integers; the Big_int module Big_int used by Num for its large integer support, but if you only need large integers, not fractions, you can simply use Big_int directly. Both are part of the Num library.

+4
source

All Articles