ocaml/otherlibs/num
Fabrice Le Fessant a20f6e647b Fix PR#6164
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14075 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-09-07 07:14:19 +00:00
..
.depend PR#4243: make the Makefiles parallelizable 2013-07-24 14:39:31 +00:00
.depend.nt clean up spaces and tabs 2010-01-22 12:48:24 +00:00
Makefile Removed the obsolete native-code generators for Alpha, HPPA, IA64 and MIPS. 2011-12-18 09:52:52 +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 renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
arith_flags.mli renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
arith_status.ml renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
arith_status.mli renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
big_int.ml PR#4323: have "of_string" in Num and Big_int work with binary and hexa representations [patch by zoep] 2013-08-04 19:58:03 +00:00
big_int.mli Wrong quoting chase. 2013-05-29 18:05:44 +00:00
bng.c Port to the ARM 64-bits (AArch64) architecture (experimental). 2013-07-18 16:09:20 +00:00
bng.h renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +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 renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +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 renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
int_misc.mli renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +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 Fix PR#6164 2013-09-07 07:14:19 +00:00
nat.mli renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
nat_stubs.c clean up TABs and whitespace 2012-07-30 18:04:46 +00:00
num.ml renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
num.mli Fix PR#5479 2012-01-17 20:32:33 +00:00
nums.mllib Add many .mllib .mlpack .clib .dlib files 2007-02-07 09:52:28 +00:00
ratio.ml renaming of Objective Caml to OCaml and cleanup of copyright headers 2011-07-27 14:17:02 +00:00
ratio.mli PR#5310: Ratio.create_ratio/create_normalized_ratio have misleading names 2012-03-31 22:15:34 +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)