ocaml/otherlibs/num
Xavier Leroy d9be4fee6a Portage PowerPC 64 bits
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7430 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2006-05-31 08:16:34 +00:00
..
bignum Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
test Remplacement long/unsigned long par intnat/uintnat 2005-09-22 14:21:50 +00:00
.cvsignore ajout so_locations dans .cvsignore 2001-10-11 12:04:40 +00:00
.depend fusion des changements jusqu'a 3.08.3 2005-03-24 17:20:54 +00:00
.depend.nt MAJ .depend.nt (PR#3707) 2005-09-24 08:59:59 +00:00
Makefile des ignores partout pour supprimer les warnins S 2005-01-21 14:15:44 +00:00
Makefile.nt Spurious option -O 2006-05-09 16:02:33 +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 fusion des modifs de 3.08.4 2005-08-13 20:59:37 +00:00
big_int.mli Retour en arriere sur l'exponentiation modulaire, pas correcte 2002-03-14 20:12:54 +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
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
nat.h Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
nat.ml des ignores partout pour supprimer les warnins S 2005-01-21 14:15:44 +00:00
nat.mli Primitive C pour l'elevation au carre 2003-11-07 07:59:10 +00:00
nat_stubs.c Remplacement long/unsigned long par intnat/uintnat 2005-09-22 14:21:50 +00:00
num.ml des ignores partout pour supprimer les warnins S 2005-01-21 14:15:44 +00:00
num.mli changement niveaux de titre dans les commentaires 2001-12-28 23:15:23 +00:00
ratio.ml des ignores partout pour supprimer les warnins S 2005-01-21 14:15:44 +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)