ocaml/otherlibs/num
Damien Doligez bdc0fadee2 merge changes from release/3.11.1 to release/3.11.2
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9540 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-01-20 16:26:46 +00:00
..
bignum Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
test merge changes from ocaml3111rc0 to ocaml3111 2009-07-20 11:51:50 +00:00
.cvsignore merge changes from release/3.11.1 to release/3.11.2 2010-01-20 16:26:46 +00:00
.depend merge changes from release/3.11.1 to release/3.11.2 2010-01-20 16:26:46 +00:00
.depend.nt MAJ .depend.nt (PR#3707) 2005-09-24 08:59:59 +00:00
Makefile Clean also emacs generated ~ files. 2008-09-10 16:10:43 +00:00
Makefile.nt Merge the natdynlink branch into HEAD. 2007-11-06 15:16:56 +00:00
README MAJ 2003-10-26 09:35:41 +00:00
arith_flags.ml MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +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 MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
arith_status.mli MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
big_int.ml merge changes from ocaml3111rc0 to ocaml3111 2009-07-20 11:51:50 +00:00
big_int.mli PR#4641: added bitwise operation to Big_int 2009-04-01 16:20:20 +00:00
bng.c Remplacement long/unsigned long par intnat/uintnat 2005-09-22 14:21:50 +00:00
bng.h Remplacement long/unsigned long par intnat/uintnat 2005-09-22 14:21:50 +00:00
bng_alpha.c Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
bng_amd64.c Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
bng_digit.c Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
bng_ia32.c fusion des modifs de 3.08.4 2005-08-13 20:59:37 +00:00
bng_mips.c Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +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
dllnums.dlib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +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 Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
nat.ml PR#4371: added conversions between big_int and int32/int64/nativeint 2008-01-04 13:15:52 +00:00
nat.mli PR#4371: added conversions between big_int and int32/int64/nativeint 2008-01-04 13:15:52 +00:00
nat_stubs.c merge changes from release/3.11.1 to release/3.11.2 2010-01-20 16:26:46 +00:00
num.ml A better implementation for quo_num and mod_num. 2008-09-10 16:12:05 +00:00
num.mli changement niveaux de titre dans les commentaires 2001-12-28 23:15:23 +00:00
nums.mllib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +00:00
ratio.ml PR#4566: bugs in approx_{ratio/num}_fix. 2008-08-03 09:04:40 +00:00
ratio.mli MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +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)