ocaml/otherlibs/num
Damien Doligez 0225ca01e3 GC latency improvements 2015-12-21 14:27:46 +01:00
..
.depend GC latency improvements 2015-12-21 14:27:46 +01:00
.depend.nt clean up spaces and tabs 2010-01-22 12:48:24 +00:00
Makefile merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev 16205) 2015-07-17 14:31:05 +00:00
Makefile.nt PR#5179: giant steps towards a Mingw64 port. 2011-12-21 16:31:01 +00:00
README clean up spaces and tabs 2010-01-22 12:48:24 +00:00
arith_flags.ml remove $Id markers 2014-04-17 09:48:35 +00:00
arith_flags.mli remove $Id markers 2014-04-17 09:48:35 +00:00
arith_status.ml remove $Id markers 2014-04-17 09:48:35 +00:00
arith_status.mli remove $Id markers 2014-04-17 09:48:35 +00:00
big_int.ml Delete historical french comments in num library 2015-10-09 20:41:47 +00:00
big_int.mli PR#7096: fix superscripts in big_int documentation 2015-12-17 09:10:27 +01:00
bng.c PR#5887: move the byterun/*.h headers to byterun/caml/*.h to avoid header name clashes 2014-12-27 14:41:49 +00:00
bng.h PR#5887: move the byterun/*.h headers to byterun/caml/*.h to avoid header name clashes 2014-12-27 14:41:49 +00:00
bng_amd64.c renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
bng_arm64.c Port to the ARM 64-bits (AArch64) architecture (experimental). 2013-07-18 16:09:20 +00:00
bng_digit.c Use 32x32->64 multiplication as provided by the C compiler when possible. 2013-07-18 16:08:11 +00:00
bng_ia32.c renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
bng_ppc.c PowerPC port of ocamlopt: 2015-07-20 15:41:44 +00:00
bng_sparc.c renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
int_misc.ml remove $Id markers 2014-04-17 09:48:35 +00:00
int_misc.mli remove $Id markers 2014-04-17 09:48:35 +00:00
libnums.clib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +00:00
nat.h renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
nat.ml Delete historical french comments in num library 2015-10-09 20:41:47 +00:00
nat.mli remove $Id markers 2014-04-17 09:48:35 +00:00
nat_stubs.c PR#5887: move the byterun/*.h headers to byterun/caml/*.h to avoid header name clashes 2014-12-27 14:41:49 +00:00
num.ml Delete historical french comments in num library 2015-10-09 20:41:47 +00:00
num.mli PR#6494 backtrack: revert the new 'equal' functions from Num and Big_int 2014-12-21 12:06:20 +00:00
nums.mllib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +00:00
ratio.ml Delete historical french comments in num library 2015-10-09 20:41:47 +00:00
ratio.mli remove $Id markers 2014-04-17 09:48:35 +00:00

README

The "libnum" library implements exact-precision arithmetic on
big integers and on rationals.

This library is derived from Valerie Menissie-Morain's implementation
of rational arithmetic for Caml V3.1 (INRIA).  Xavier Leroy (INRIA)
did the Caml Light port.  Victor Manuel Gulias Fernandez did the
initial Caml Special Light port.  Pierre Weis did most of the
maintenance and bug fixing.

Initially, the low-level big integer operations were provided by the
BigNum package developed by Bernard Serpette, Jean Vuillemin and
Jean-Claude Herve (INRIA and Digital PRL).  License issues forced us to
replace the BigNum package.  The current implementation of low-level
big integer operations is due to Xavier Leroy.

This library is documented in "The CAML Numbers Reference Manual" by
Valerie Menissier-Morain, technical report 141, INRIA, july 1992,
available at ftp://ftp.inria.fr/INRIA/publication/RT/RT-0141.ps.gz


USAGE:

To use the bignum library from your programs, just do

    ocamlc <options> nums.cma <.cmo and .ml files>
or
    ocamlopt <options> nums.cmxa <.cmx and .ml files>

for the linking phase.

If you'd like to have the bignum functions available at toplevel, do

    ocamlmktop -o ocamltopnum <options> nums.cma <.cmo and .ml files>
    ./ocamltopnum

As an example, try:

        open Num;;
        let rec fact n =
          if n = 0 then Int 1 else mult_num (num_of_int n) (fact(n-1));;
        string_of_num(fact 1000);;


PROCESSOR-SPECIFIC OPTIMIZATIONS:

When compiled with GCC, the low-level primitives use "inline extended asm"
to exploit useful features of the target processor (additions and
subtractions with carry; double-width multiplication, division).
Here are the processors for which such optimizations are available:
  IA32 (x86)       (carry, dwmult, dwdiv, 64-bit ops with SSE2 if available)
  AMD64 (Opteron)  (carry, dwmult, dwdiv)
  PowerPC          (carry, dwmult)
  Alpha            (dwmult)
  SPARC            (carry, dwmult, dwdiv)
  MIPS             (dwmult)