OCaml needs an arbitrary-precision decimal type

I’ve mentioned this before: What libraries are missing?

But pulling it into a new thread because I have a specific ask: is someone willing to contribute a decimal number implementation to OCaml?

I realize OCaml has historically had a minimalist standard library philosophy, e.g. it’s reasonable to not include a JSON data type, but I believe decimal numbers are a fairly fundamental type especially for business applications. Major industrial language platforms tend to agree:

And even newer ones:

So, I thought I’d bring it up again, as it’s really pretty foundational IMHO.


You’re going at this wrong.

The first step of putting anything in the stdlib is to actually write a library that does it.

So, if you want it, start by writing the library. Publish it, iterate on the design and then maybe propose it. Worse case, you’ll have a good decimal library.

1 Like

Well, I really do believe it should be in the standard library, but I have nothing against starting it as a separate package. In either case, my main question is still: is anyone willing to contribute one?

I’ve kicked off the process of releasing Jane Street’s arbitrary precision decimal type, called Bigdecimal. It should hit github in a few days, I expect.



Thank you very much, that is very generous. I’ve been working on a straight-up port of the Python decimal module to OCaml for the past few days, but of course Jane Street’s Bigdecimal will be much more trustworthy than my home-grown effort :slight_smile:

1 Like

Our Bigdecimal library is now live:

It won’t be in the ordinary Opam repo until our next stable release, which is scheduled for early 2021.