ocaml/otherlibs/num
Xavier Leroy 5eb0a9bbee Bug fix pour portage Mingw
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6180 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-04-01 13:10:12 +00:00
..
bignum Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
test Bug fix pour portage Mingw 2004-04-01 13:10:12 +00:00
.cvsignore ajout so_locations dans .cvsignore 2001-10-11 12:04:40 +00:00
.depend decontamination (PR#1914, PR#1956) 2003-12-15 18:10:51 +00:00
.depend.nt Chargement dynamique de primitives C 2001-08-28 14:47:48 +00:00
Makefile Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
Makefile.nt Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +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 PR#1989 2003-12-29 19:26:15 +00:00
big_int.mli Retour en arriere sur l'exponentiation modulaire, pas correcte 2002-03-14 20:12:54 +00:00
bng.c Primitive C pour l'elevation au carre 2003-11-07 07:59:10 +00:00
bng.h Primitive C pour l'elevation au carre 2003-11-07 07:59:10 +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 Typo dans sse2_mult_sub 2003-10-26 09:51:11 +00:00
bng_mips.c Remplacement de la couche basse BigNum 2003-10-24 09:18:01 +00:00
bng_ppc.c Typo dans BngSub3 2003-10-27 08:41:46 +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 Attention aux litteraux qui debordent en 32 bits. 2003-11-21 15:59:38 +00:00
nat.mli Primitive C pour l'elevation au carre 2003-11-07 07:59:10 +00:00
nat_stubs.c Primitive C pour l'elevation au carre 2003-11-07 07:59:10 +00:00
num.ml MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
num.mli changement niveaux de titre dans les commentaires 2001-12-28 23:15:23 +00:00
ratio.ml MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
ratio.mli MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
string_misc.ml MAJ en-tetes pour mentionner la 'special exception' sur la LGPL 2001-12-07 13:41:02 +00:00
string_misc.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)