package bignum

  1. Overview
  2. Docs
Core-flavoured wrapper around zarith's arbitrary-precision rationals


Dune Dependency





Release v0.16.0

  • Big_int

    • Adds stable_witness derivation to both the BigInt.Stable.V1 and BigInt.Stable.V2 modules. This facilitates compatibility checks between different versions of serialized data

  • Big_num

    • Add deriving attributes:

      • Bignum.t, Bignum.Stable.t, and Bignum.Unstable.t derive sexp_grammar

    • Add new functions to Bignum:

      • truncate: Rounds the input towards zero to an integer

      • is_infinite: Returns true if the number is either positive or negative infinity

      • is_positive_infinity: Returns true if the number is positive infinity

      • is_negative_infinity: Returns true if the number is negative infinity

    • Add arg_type to Bignum, for ease of use in Command.t based parsers

Old pre-v0.15 changelogs (very likely stale and incomplete)


  • This release improves the slow path of bignum of string. The previous version used a split on '_' followed by a concat, which allocated a bunch of intermediate strings.


  • Switched to PPX.

  • The library used polymorphic compare, rather than Zarith.Q's compare, in a few locations. Fixed this.

  • Previously stable types in Bignum were defined with unstable types in the scope. Fixd this.

  • Update to zarith-1.4


  • Fixed a bug in the =Zarith= library's to_float function.

    These fixes first introduce tests from the base distribution, and then backport a bugfix to the handling of to_float.


  • Upgraded from Zarith 1.2 to 1.3.

  • Removed dependence on Big_int.


  • Fixed exception raised by Bignum.sexp_of_t when the denominator is zero.


  • Added Bigint.random function, which produces a uniformly distributed value.


  • Added functions to round from Bignum.t to Bigint.t, and to convert Bigint.t into Bignum.t.


  • Added Bignum.Bigint module, with arbitrary-precision integers based on Zarith, which is significantly faster than the Num.Big_int library.


  • Improved the performance of binprot deserialization by removing the allocation of an intermediate type.


  • Eliminated the dependence of Bignum on Re2, and reduced dependence from Core to Core_kernel.

  • Extended the rounding interface to bring it in line with int and float rounding.

  • Improved the performance of Bignum's binprot.

    Bignum's binprot had been to just binprot the decimal string representation. This is both slow to do and unnecessarily big in the majority of cases. Did something better in the majority of cases and fell back to this representation in the exceptional case.

      $ ./inline_benchmarks_runner
      Estimated testing time 20s (2 benchmarks x 10s). Change using -quota SECS.
    Name Time/Run mWd/Run Percentage binprot roundtrip compact 7.87us 490.00w 32.88% binprot roundtrip classic 23.94us 1_079.00w 100.00%

Innovation. Community. Security.