ocaml/otherlibs/num
Nicolas Pouillard 0d72001f2a Merge branch 'ocaml-git/buildsys' (early part) into trunk
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10386 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-11 13:34:20 +00:00
..
bignum Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
.cvsignore merge changes from release/3.11.1 to release/3.11.2 2010-01-20 16:26:46 +00:00
.depend New -help-warnings command-line option. 2010-05-04 18:44:38 +00:00
.depend.nt clean up spaces and tabs 2010-01-22 12:48:24 +00:00
Makefile test directory was removed -- portable version 2010-02-09 14:17:20 +00:00
Makefile.nt Fix 'make clean' under Windows. 2010-04-30 13:27:35 +00:00
README clean up spaces and tabs 2010-01-22 12:48:24 +00:00
arith_flags.ml clean up spaces and tabs 2010-01-22 12:48:24 +00:00
arith_flags.mli MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
arith_status.ml clean up spaces and tabs 2010-01-22 12:48:24 +00:00
arith_status.mli clean up spaces and tabs 2010-01-22 12:48:24 +00:00
big_int.ml PR#5017: shift_right_big_int on negative numbers 2010-04-29 13:53:01 +00:00
big_int.mli PR#5017: shift_right_big_int on negative numbers 2010-04-29 13:53:01 +00:00
bng.c clean up spaces and tabs 2010-01-22 12:48:24 +00:00
bng.h clean up spaces and tabs 2010-01-22 12:48:24 +00:00
bng_alpha.c clean up spaces and tabs 2010-01-22 12:48:24 +00:00
bng_amd64.c clean up spaces and tabs 2010-01-22 12:48:24 +00:00
bng_digit.c PR#4676: wrong constant in Win64 IL32LLP64 model 2010-04-28 11:59:09 +00:00
bng_ia32.c clean up spaces and tabs 2010-01-22 12:48:24 +00:00
bng_mips.c clean up spaces and tabs 2010-01-22 12:48:24 +00:00
bng_ppc.c Portage PowerPC 64 bits 2006-05-31 08:16:34 +00:00
bng_sparc.c Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
int_misc.ml Retour en arriere sur le precedent commit 2002-05-27 12:06:49 +00:00
int_misc.mli MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
libnums.clib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +00:00
nat.h clean up spaces and tabs 2010-01-22 12:48:24 +00:00
nat.ml clean up spaces and tabs 2010-01-22 12:48:24 +00:00
nat.mli clean up spaces and tabs 2010-01-22 12:48:24 +00:00
nat_stubs.c clean up spaces and tabs 2010-01-22 12:48:24 +00:00
num.ml clean up spaces and tabs 2010-01-22 12:48:24 +00:00
num.mli clean up spaces and tabs 2010-01-22 12:48:24 +00:00
nums.mllib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +00:00
ratio.ml clean up spaces and tabs 2010-01-22 12:48:24 +00:00
ratio.mli clean up spaces and tabs 2010-01-22 12:48:24 +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)