[BACK]Return to gmp.info-1 CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp

Diff for /OpenXM_contrib/gmp/Attic/gmp.info-1 between version 1.1.1.1 and 1.1.1.3

version 1.1.1.1, 2000/01/10 15:35:21 version 1.1.1.3, 2000/12/01 05:44:45
Line 1 
Line 1 
 This is Info file gmp.info, produced by Makeinfo-1.64 from the input  This is gmp.info, produced by makeinfo version 4.0 from gmp.texi.
 file gmp.texi.  
   
   INFO-DIR-SECTION GNU libraries
 START-INFO-DIR-ENTRY  START-INFO-DIR-ENTRY
 * gmp: (gmp.info).               GNU Multiple Precision Arithmetic Library.  * gmp: (gmp).                   GNU Multiple Precision Arithmetic Library.
 END-INFO-DIR-ENTRY  END-INFO-DIR-ENTRY
   
    This file documents GNU MP, a library for arbitrary-precision     This file documents GNU MP, a library for arbitrary-precision
 arithmetic.  arithmetic.
   
    Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation,     Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
 Inc.  Free Software Foundation, Inc.
   
    Permission is granted to make and distribute verbatim copies of this     Permission is granted to make and distribute verbatim copies of this
 manual provided the copyright notice and this permission notice are  manual provided the copyright notice and this permission notice are
Line 32  GNU MP
Line 32  GNU MP
 ******  ******
   
    This manual documents how to install and use the GNU multiple     This manual documents how to install and use the GNU multiple
 precision arithmetic library, version 2.0.2.  precision arithmetic library, version 3.1.1.
   
 * Menu:  * Menu:
   
 * Copying::                   GMP Copying Conditions (LGPL).  * Copying::                    GMP Copying Conditions (LGPL).
 * Introduction to MP::        Brief introduction to GNU MP.  * Introduction to GMP::        Brief introduction to GNU MP.
 * Installing MP::             How to configure and compile the MP library.  * Installing GMP::             How to configure and compile the GMP library.
 * MP Basics::                 What every MP user should now.  * GMP Basics::                 What every GMP user should now.
 * Reporting Bugs::            How to usefully report bugs.  * Reporting Bugs::             How to usefully report bugs.
 * Integer Functions::         Functions for arithmetic on signed integers.  * Integer Functions::          Functions for arithmetic on signed integers.
 * Rational Number Functions:: Functions for arithmetic on rational numbers.  * Rational Number Functions::  Functions for arithmetic on rational numbers.
 * Floating-point Functions::  Functions for arithmetic on floats.  * Floating-point Functions::   Functions for arithmetic on floats.
 * Low-level Functions::       Fast functions for natural numbers.  * Low-level Functions::        Fast functions for natural numbers.
 * BSD Compatible Functions::  All functions found in BSD MP.  * Random Number Functions::    Functions for generating random numbers.
 * Custom Allocation::         How to customize the internal allocation.  * BSD Compatible Functions::   All functions found in BSD MP.
   * Custom Allocation::          How to customize the internal allocation.
   
 * Contributors::  * Contributors::               Who brings your this library?
 * References::  * References::                 Some useful papers and books to read.
 * Concept Index::  * Concept Index::
 * Function Index::  * Function Index::
   
   
 File: gmp.info,  Node: Copying,  Next: Introduction to MP,  Prev: Top,  Up: Top  File: gmp.info,  Node: Copying,  Next: Introduction to GMP,  Prev: Top,  Up: Top
   
 GNU MP Copying Conditions  GNU MP Copying Conditions
 *************************  *************************
Line 85  know that what they have is not what we distributed, s
Line 86  know that what they have is not what we distributed, s
 problems introduced by others will not reflect on our reputation.  problems introduced by others will not reflect on our reputation.
   
    The precise conditions of the license for the GNU MP library are     The precise conditions of the license for the GNU MP library are
 found in the Library General Public License that accompany the source  found in the Lesser General Public License that accompany the source
 code.  code.
   
   
 File: gmp.info,  Node: Introduction to MP,  Next: Installing MP,  Prev: Copying,  Up: Top  File: gmp.info,  Node: Introduction to GMP,  Next: Installing GMP,  Prev: Copying,  Up: Top
   
 Introduction to GNU MP  Introduction to GNU MP
 **********************  **********************
Line 101  that need higher precision than is directly supported 
Line 102  that need higher precision than is directly supported 
 types.  types.
   
    Many applications use just a few hundred bits of precision; but some     Many applications use just a few hundred bits of precision; but some
 applications may need thousands or even millions of bits.  MP is  applications may need thousands or even millions of bits.  GMP is
 designed to give good performance for both, by choosing algorithms  designed to give good performance for both, by choosing algorithms
 based on the sizes of the operands, and by carefully keeping the  based on the sizes of the operands, and by carefully keeping the
 overhead at a minimum.  overhead at a minimum.
   
    The speed of MP is achieved by using fullwords as the basic     The speed of GMP is achieved by using fullwords as the basic
 arithmetic type, by using sophisticated algorithms, by including  arithmetic type, by using sophisticated algorithms, by including
 carefully optimized assembly code for the most common inner loops for  carefully optimized assembly code for the most common inner loops for
 many different CPUs, and by a general emphasis on speed (as opposed to  many different CPUs, and by a general emphasis on speed (as opposed to
 simplicity or elegance).  simplicity or elegance).
   
    There is carefully optimized assembly code for these CPUs: DEC     There is carefully optimized assembly code for these CPUs: ARM, DEC
 Alpha, Amd 29000, HPPA 1.0 and 1.1, Intel Pentium and generic x86,  Alpha 21064, 21164, and 21264, AMD 29000, AMD K6 and Athlon, Hitachi
 Intel i960, Motorola MC68000, MC68020, MC88100, and MC88110,  SuperH and SH-2, HPPA 1.0, 1.1 and 2.0, Intel Pentium, Pentium
 Motorola/IBM PowerPC, National NS32000, IBM POWER, MIPS R3000, R4000,  Pro/Pentium II, generic x86, Intel i960, Motorola MC68000, MC68020,
 SPARCv7, SuperSPARC, generic SPARCv8, and DEC VAX.  Some optimizations  MC88100, and MC88110, Motorola/IBM PowerPC 32 and 64, National NS32000,
 also for ARM, Clipper, IBM ROMP (RT), and Pyramid AP/XP.  IBM POWER, MIPS R3000, R4000, SPARCv7, SuperSPARC, generic SPARCv8,
   UltraSPARC, DEC VAX, and Zilog Z8000.  Some optimizations also for
   Clipper, IBM ROMP (RT), and Pyramid AP/XP.
   
    This version of MP is released under a more liberal license than     There is a mailing list for GMP users.  To join it, send a mail to
 previous versions.  It is now permitted to link MP to non-free  <gmp-request@swox.com> with the word `subscribe' in the message *body*
 programs, as long as MP source code is provided when distributing the  (not in the subject line).
 non-free program.  
   
      For up-to-date information on GMP, please see the GMP Home Pages at
   `http://www.swox.com/gmp/'.
   
 How to use this Manual  How to use this Manual
 ======================  ======================
   
    Everyone should read *Note MP Basics::.  If you need to install the     Everyone should read *Note GMP Basics::.  If you need to install the
 library yourself, you need to read *Note Installing MP::, too.  library yourself, you need to read *Note Installing GMP::, too.
   
    The rest of the manual can be used for later reference, although it     The rest of the manual can be used for later reference, although it
 is probably a good idea to glance through it.  is probably a good idea to glance through it.
   
   
 File: gmp.info,  Node: Installing MP,  Next: MP Basics,  Prev: Introduction to MP,  Up: Top  File: gmp.info,  Node: Installing GMP,  Next: GMP Basics,  Prev: Introduction to GMP,  Up: Top
   
 Installing MP  Installing GMP
 *************  **************
   
    To build MP, you first have to configure it for your CPU and  GMP has an autoconf/automake/libtool based configuration system.  On a
 operating system.  You need a C compiler, preferably GCC, but any  Unix-like system a basic build can be done with
 reasonable compiler should work.  And you need a standard Unix `make'  
 program, plus some other standard Unix utility programs.  
   
    (If you're on an MS-DOS machine, your can build MP using `make.bat'.       ./configure
 It requires that djgpp is installed.  It does not require       make
 configuration, nor is `make' needed; `make.bat' both configures and  
 builds the library.)  
   
    Here are the steps needed to install the library on Unix systems:  Some self-tests can be run with
   
   1. In most cases, `./configure --target=cpu-vendor-os', should work       make check
      both for native and cross-compilation.  If you get error messages,  
      your machine might not be supported.  
   
      If you want to compile in a separate object directory, cd to that  And you can install (under `/usr/local' by default) with
      directory, and prefix the configure command with the path to the  
      MP source directory.  Not all `make' programs have the necessary  
      features to support this.  In particular, SunOS and Slowaris  
      `make' have bugs that makes them unable to build from a separate  
      object directory.  Use GNU `make' instead.  
   
      In addition to the standard cpu-vendor-os tuples, MP recognizes       make install
      sparc8 and supersparc as valid CPU names.  Specifying these CPU  
      names for relevant systems will improve performance significantly.  
   
   If you experience problems, please report them to <bug-gmp@gnu.org>.
   (*Note Reporting Bugs::, for information on what to include in useful
   bug reports.)
   
   * Menu:
   
   * Build Options::
   * ABI and ISA::
   * Notes for Package Builds::
   * Notes for Particular Systems::
   * Known Build Problems::
   
   
   File: gmp.info,  Node: Build Options,  Next: ABI and ISA,  Prev: Installing GMP,  Up: Installing GMP
   
   Build Options
   =============
   
   All the usual autoconf configure options are available, run `./configure
   --help' for a summary.
   
   Non-Unix Systems
        `configure' needs various Unix-like tools installed.  On an MS-DOS
        system cygwin or djgpp should work.  It might be possible to build
        without the help of `configure', certainly all the code is there,
        but unfortunately you'll be on your own.
   
   Object Directory
        To compile in a separate object directory, `cd' to that directory,
        and prefix the configure command with the path to the GMP source
        directory.  For example `../src/gmp/configure'.  Not all `make'
        programs have the necessary features (`VPATH') to support this.
        In particular, SunOS and Slowaris `make' have bugs that make them
        unable to build from a separate object directory.  Use GNU `make'
        instead.
   
   `--disable-shared', `--disable-static'
        By default both shared and static libraries are built (where
        possible), but one or other can be disabled.  Shared libraries are
        very slightly slower, having a small cost on each function call,
        but result in smaller executables and permit code sharing between
        separate running processes.
   
   `--target=CPU-VENDOR-OS'
        The build target can be specified in the usual way, for either
        native or cross compilation.
   
        If `--target' isn't given, `./configure' builds for the host
        system as determined by `./config.guess'.  On some systems this
        can't distinguish between different CPUs in a family, and you
        should check the guess.  Running `./config.guess' on the target
        system will also show the relevant `VENDOR-OS', if you don't
        already know what it should be.
   
      In general, if you want a library that runs as fast as possible,       In general, if you want a library that runs as fast as possible,
      you should make sure you configure MP for the exact CPU type your       you should configure GMP for the exact CPU type your system uses.
      system uses.       However, this may mean the binaries won't run on older members of
        the family, and might run slower on other members, older or newer.
        The best idea is always to build GMP for the exact machine type
        you intend to run it on.
   
      If you have `gcc' in your `PATH', it will be used by default.  To       The following CPU targets have specific assembly code support.  See
      override this, pass `-with-gcc=no' to `configure'.       `configure.in' for which `mpn' subdirectories get used by each.
   
   2. `make'          * Alpha: `alpha', `alphaev5', `alphaev6'
   
      This will compile MP, and create a library archive file `libgmp.a'          * Hitachi: `sh', `sh2'
      in the working directory.  
   
   3. `make check'          * HPPA: `hppa1.0', `hppa1.1', `hppa2.0', `hppa2.0w'
   
      This will make sure MP was built correctly.  If you get error          * MIPS: `mips', `mips3',
      messages, please report this to `bug-gmp@prep.ai.mit.edu'.  (*Note  
      Reporting Bugs::, for information on what to include in useful bug  
      reports.)  
   
   4. `make install'          * Motorola: `m68000', `m68k', `m88k', `m88110'
   
      This will copy the file `gmp.h' and `libgmp.a', as well as the info          * POWER: `power1', `power2', `power2sc', `powerpc', `powerpc64'
      files, to `/usr/local' (or if you passed the `--prefix' option to  
      `configure', to the directory given as argument to `--prefix').  
   
 If you wish to build and install the BSD MP compatible functions, use          * SPARC: `sparc', `sparcv8', `microsparc', `supersparc',
 `make libmp.a' and `make install-bsdmp'.            `sparcv9', `ultrasparc', `sparc64'
   
    There are some other useful make targets:          * 80x86 family: `i386', `i486', `i586', `pentium', `pentiummmx',
             `pentiumpro', `pentium2', `pentium3', `k6', `k62', `k63',
             `athlon'
   
    * `doc'          * Other: `a29k', `arm', `clipper', `i960', `ns32k', `pyramid',
             `vax', `z8k'
   
      Create a DVI version of the manual, in `gmp.dvi' and a set of info       CPUs not listed use generic C code.  If some of the assembly code
      files, in `gmp.info', `gmp.info-1', `gmp.info-2', etc.       causes problems, the generic C code can be selected with CPU
        `none'.
   
    * `ps'  `CC', `CFLAGS'
        The C compiler used is chosen from among some likely candidates,
        with GCC normally preferred if it's present.  The usual
        `CC=whatever' can be passed to `./configure' to choose something
        different.
   
      Create a Postscript version of the manual, in `gmp.ps'.       For some configurations specific compiler flags are set based on
        the target CPU and compiler, see `CFLAGS' in the generated
        `Makefile's.  The usual `CFLAGS="-whatever"' can be passed to
        `./configure' to use something different or to set good flags for
        systems GMP doesn't otherwise know.
   
    * `html'       Note that if `CC' is set then `CFLAGS' must also be set.  This
        applies even if `CC' is merely one of the choices GMP would make
        itself.  This may change in a future release.
   
      Create a HTML version of the manual, in `gmp.html'.  `--disable-alloca'
        By default, GMP allocates temporary workspace using `alloca' if
        that function is available, or `malloc' if not.  If you're working
        with large numbers and `alloca' overflows the available stack
        space, you can build with `--disable-alloca' to use `malloc'
        instead.  `malloc' will probably be slightly slower than `alloca'.
   
    * `clean'       When not using `alloca', it's actually the allocation function
        selected with `mp_set_memory_functions' that's used, this being
        `malloc' by default.  *Note Custom Allocation::.
   
      Delete all object files and archive files, but not the       Depending on your system, the only indication of stack overflow
      configuration files.       might be a segmentation violation.  It might be possible to
        increase available stack space with `limit', `ulimit' or
        `setrlimit', or under DJGPP with `stubedit' or `_stklen'.
   
    * `distclean'  `--enable-fft'
        By default multiplications are done using Karatsuba and 3-way
        Toom-Cook algorithms, but a Fermat FFT can be enabled, for use on
        large to very large operands.  Currently the FFT is recommended
        only for knowledgeable users who check the algorithm thresholds
        for their CPU.
   
      Delete all files not included in the distribution.  `--enable-mpbsd'
        The Berkeley MP compatibility library (`libmp.a') and header file
        (`mp.h') are built and installed only if `--enable-mpbsd' is used.
        *Note BSD Compatible Functions::.
   
    * `uninstall'  `MPN_PATH'
        Various assembler versions of mpn subroutines are provided, and,
        for a given CPU target, a search is made though a path to choose a
        version of each.  For example `sparcv8' has path `"sparc32/v8
        sparc32 generic"', which means it looks first for v8 code, falls
        back on plain sparc32, and finally falls back on generic C.
        Knowledgeable users with special requirements can specify a path
        with `MPN_PATH="dir list"'.  This will normally be unnecessary
        because all sensible paths should be available under one or other
        CPU target.
   
      Delete all files copied by `make install'.  Demonstration Programs
        The `demos' subdirectory has some sample programs using GMP.  These
        aren't built or installed, but there's a `Makefile' with rules for
        them.  For instance, `make pexpr' and then `./pexpr 68^975+10'.
   
   Documentation
        The document you're now reading is `gmp.texi'.  The usual automake
        targets are available to make `gmp.ps' and/or `gmp.dvi'.  Some
        supplementary notes can be found in the `doc' subdirectory.
   
   
   File: gmp.info,  Node: ABI and ISA,  Next: Notes for Package Builds,  Prev: Build Options,  Up: Installing GMP
   
   ABI and ISA
   ===========
   
      ABI (Application Binary Interface) refers to the calling conventions
   between functions, meaning what registers are used and what sizes the
   various C data types are.  ISA (Instruction Set Architecture) refers to
   the instructions and registers a CPU has available.
   
      Some 64-bit ISA CPUs have both a 64-bit ABI and a 32-bit ABI
   defined, the latter for compatibility with older CPUs in the family.
   GMP chooses the best ABI available for a given target system, and this
   generally gives significantly greater speed.
   
      The burden is on application programs and cooperating libraries to
   ensure they match the ABI chosen by GMP.  Fortunately this presents a
   difficulty only on a few systems, and if you have one of them then the
   performance gains are enough to make it worth the trouble.
   
      Some of what's described in this section may change in future
   releases of GMP.
   
   HPPA 2.0
        CPU target `hppa2.0' uses the hppa2.0n 32-bit ABI, but either a
        32-bit or 64-bit limb.
   
        A 64-bit limb is available on HP-UX 10 or up when using `c89'.  No
        `gcc' support is planned for 64-bit operations in this ABI.
        Applications must be compiled with the same options as GMP, which
        means
   
             c89  +DA2.0 +e -D_LONG_LONG_LIMB
   
        A 32-bit limb is used in other cases, and no special compiler
        options are needed.
   
        CPU target `hppa2.0w' uses the hppa2.0w 64-bit ABI, which is
        available on HP-UX 11 or up when using `c89'.  `gcc' support for
        this is in progress.  Applications must be compiled for the same
        ABI, which means
   
             c89  +DD64
   
   MIPS 3 and 4 under IRIX 6
        Targets `mips*-*-irix6*' use the n32 ABI and a 64-bit limb.
        Applications must be compiled for the same ABI, which means either
   
             gcc  -mabi=n32
             cc   -n32
   
   PowerPC 64
        CPU target `powerpc64' uses either the 32-bit ABI or the AIX
        64-bit ABI.  The latter is used on targets `powerpc64-*-aix*' and
        applications must be compiled using either
   
             gcc  -maix64
             xlc  -q64
   
        On other systems the 32-bit ABI is used, but with 64-bit limbs
        provided by `long long' in `gcc'.  Applications must be compiled
        using
   
             gcc  -D_LONG_LONG_LIMB
   
   Sparc V9
        On a sparc v9 CPU, either the v8plus 32-bit ABI or v9 64-bit ABI
        is used.  Targets `ultrasparc*-*-solaris2.[7-9]',
        `sparcv9-*-solaris2.[7-9]' and `sparc64-*-linux*' use the v9 ABI,
        if the compiler supports it.  Other targets use the v8plus ABI
        (but with as much of the v9 ISA as possible in the circumstances).
        Note that Solaris prior to 2.7 doesn't save all registers
        properly, and hence uses the v8plus ABI.
   
        For the v8plus ABI, applications can be compiled with either
   
             gcc  -mv8plus
             cc   -xarch=v8plus
   
        For the v9 ABI, applications must be compiled with either
   
             gcc  -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9
             cc   -xarch=v9
   
        Don't be confused by the names of these options, they're called
        `arch' but they effectively control the ABI.
   
   
   File: gmp.info,  Node: Notes for Package Builds,  Next: Notes for Particular Systems,  Prev: ABI and ISA,  Up: Installing GMP
   
   Notes for Package Builds
   ========================
   
      GMP should present no great difficulties for packaging in a binary
   distribution.
   
      Libtool is used to build the library and `-version-info' is set
   appropriately, having started from `3:0:0' in GMP 3.0.  The GMP 3 series
   will be upwardly binary compatible in each release, but may be adding
   additional function interfaces.  On systems where libtool versioning is
   not fully checked by the loader, an auxiliary mechanism may be needed
   to express that a dynamic linked application depends on a new enough
   minor version of GMP.
   
      When building a package for a CPU family, care should be taken to use
   `--target' to choose the least common denominator among the CPUs which
   might use the package.  For example this might necessitate `i386' for
   x86s, or plain `sparc' (meaning V7) for SPARCs.
   
      Users who care about speed will want GMP built for their exact CPU
   type, to make use of the available optimizations.  Providing a way to
   suitably rebuild a package may be useful.  This could be as simple as
   making it possible for a user to omit `--target' in a build so
   `./config.guess' will detect the CPU.  But a way to manually specify a
   `--target' will be wanted for systems where `./config.guess' is inexact.
   
   
   File: gmp.info,  Node: Notes for Particular Systems,  Next: Known Build Problems,  Prev: Notes for Package Builds,  Up: Installing GMP
   
   Notes for Particular Systems
   ============================
   
   AIX 4.3
        Targets `*-*-aix4.[3-9]*' have shared libraries disabled since
        they seem to fail on AIX 4.3.
   
   OpenBSD 2.6
        `m4' in this release of OpenBSD has a bug in `eval' that makes it
        unsuitable for `.asm' file processing.  `./configure' will detect
        the problem and either abort or choose another m4 in the `PATH'.
        The bug is fixed in OpenBSD 2.7, so either upgrade or use GNU m4.
   
   Sparc V8
        Using CPU target `sparcv8' or `supersparc' on relevant systems will
        give a significant performance increase over the V7 code.
   
   SunOS 4
        `/usr/bin/m4' lacks various features needed to process `.asm'
        files, and instead `./configure' will automatically use
        `/usr/5bin/m4', which we believe is always available (if not then
        use GNU m4).
   
   x86 Pentium and PentiumPro
        The Intel Pentium P5 code is good for its intended P5, but quite
        slow when run on Intel P6 class chips (PPro, P-II, P-III).  `i386'
        is a better choice if you're making binaries that must run on both.
   
   x86 MMX and old GAS
        Old versions of GAS don't support MMX instructions, in particular
        version 1.92.3 that comes with FreeBSD 2.2.8 doesn't (and
        unfortunately there's no newer assembler for that system).
   
        If the target CPU has MMX code but the assembler doesn't support
        it, a warning is given and non-MMX code is used instead.  This
        will be an inferior build, since the MMX code that's present is
        there because it's faster than the corresponding plain integer
        code.
   
   x86 GCC 2.95.2 `-march=pentiumpro'
        GCC 2.95.2 miscompiles `mpz/powm.c' when `-march=pentiumpro' is
        used, so that option is omitted from the `CFLAGS' chosen for
        relevant CPUs.  The problem is believed to be fixed in GCC 2.96.
   
   
   File: gmp.info,  Node: Known Build Problems,  Prev: Notes for Particular Systems,  Up: Installing GMP
   
 Known Build Problems  Known Build Problems
 ====================  ====================
   
    GCC 2.7.2 (as well as 2.6.3) for the RS/6000 and PowerPC can not be     You might find more up-to-date information at
 used to compile MP, due to a bug in GCC.  If you want to use GCC for  `http://www.swox.com/gmp/'.
 these machines, you need to apply the patch below to GCC, or use a  
 later version of the compiler.  
   
    If you are on a Sequent Symmetry, use the GNU assembler instead of  Generic C on a 64-bit system
 the system's assembler, since the latter has serious bugs.       When making a generic C build using `--target=none' on a 64-bit
        system (meaning where `unsigned long' is 64 bits),
        `BITS_PER_MP_LIMB', `BITS_PER_LONGINT' and `BYTES_PER_MP_LIMB' in
        `mpn/generic/gmp-mparam.h' need to be changed to 64 and 8.  This
        will hopefully be automated in a future version of GMP.
   
    The system compiler on NeXT is a massacred and old gcc, even if the  NeXT prior to 3.3
 compiler calls itself `cc'.  This compiler cannot be used to build MP.       The system compiler on old versions of NeXT was a massacred and
 You need to get a real gcc, and install that before you compile MP.       old GCC, even if it called itself `cc'.  This compiler cannot be
 (NeXT might have fixed this in newer releases of their system.)       used to build GMP, you need to get a real GCC, and install that
        before you compile GMP.  (NeXT may have fixed this in release 3.3
        of their system.)
   
    The system C compiler under SunOS 4 has a bug that makes it  POWER and PowerPC
 miscompile mpq/get_d.c.  This will make `make check' fail.       Bugs in GCC 2.7.2 (and 2.6.3) mean it can't be used to compile GMP
        on POWER or PowerPC.  If you want to use GCC for these machines,
        get GCC 2.7.2.1 (or later).
   
    Please report other problems to `bug-gmp@prep.ai.mit.edu'.  *Note  Sequent Symmetry
 Reporting Bugs::.       Use the GNU assembler instead of the system assembler, since the
        latter has serious bugs.
   
    Patch to apply to GCC 2.6.3 and 2.7.2:  Stripped Libraries
        GNU binutils `strip' should not be used on the static libraries
        `libgmp.a' and `libmp.a', neither directly nor via `make
        install-strip'.  It can be used on the shared libraries
        `libgmp.so' and `libmp.so' though.
   
      *** config/rs6000/rs6000.md        Sun Feb 11 08:22:11 1996       Currently (binutils 2.10.0), `strip' extracts archives into a
      --- config/rs6000/rs6000.md.new    Sun Feb 18 03:33:37 1996       single directory, but GMP contains multiple object files of the
      ***************       same name (eg. three versions of `init.o'), and they overwrite
      *** 920,926 ****       each other, leaving only the one that happens to be last.
           (set (match_operand:SI 0 "gpc_reg_operand" "=r")  
         (not:SI (match_dup 1)))]  
          ""  
      !   "nor. %0,%2,%1"  
          [(set_attr "type" "compare")])  
   
        (define_insn ""  
      --- 920,926 ----  
           (set (match_operand:SI 0 "gpc_reg_operand" "=r")  
         (not:SI (match_dup 1)))]  
          ""  
      !   "nor. %0,%1,%1"  
          [(set_attr "type" "compare")])  
   
        (define_insn ""  
   
        If stripped static libraries are wanted, the suggested workaround
        is to build normally, strip the separate object files, and do
        another `make all' to rebuild.  Alternately `CFLAGS' with `-g'
        omitted can always be used if it's just debugging which is
        unwanted.
   
   SunOS 4 Native Tools
        The setting for `GSYM_PREFIX' in `config.m4' may be incorrectly
        determined when using the native `grep', leading at link-time to
        undefined symbols like `___gmpn_add_n'.  To fix this, after running
        `./configure', change the relevant line in `config.m4' to
        `define(<GSYM_PREFIX>, <_>)'.
   
        The `ranlib' command will need to be run manually when building a
        static library with the native `ar'.  After `make', run `ranlib
        .libs/libgmp.a', and when using `--enable-mpbsd' run `ranlib
        .libs/libmp.a' too.
   
   `version.c' compilation
        The current `./configure' relies on certain features of `sed' that
        some old systems don't have.  One symptom is `VERSION' not being
        set correctly in the generated `config.h', leading to `version.c'
        failing to compile.  Irix 5.3, MIPS RISC/OS and Ultrix 4.4 are
        believed to be affected.  GNU `sed' is recommended, though it
        might be possible to build by editing `config.h' manually instead.
   
   VAX running Ultrix
        You need to build and install the GNU assembler before you compile
        GMP.  The VAX assembly in GMP uses an instruction (`jsobgtr') that
        cannot be assembled by the Ultrix assembler.
   
   
 File: gmp.info,  Node: MP Basics,  Next: Reporting Bugs,  Prev: Installing MP,  Up: Top  File: gmp.info,  Node: GMP Basics,  Next: Reporting Bugs,  Prev: Installing GMP,  Up: Top
   
 MP Basics  GMP Basics
 *********  **********
   
    All declarations needed to use MP are collected in the include file     All declarations needed to use GMP are collected in the include file
 `gmp.h'.  It is designed to work with both C and C++ compilers.  `gmp.h'.  It is designed to work with both C and C++ compilers.
   
      *Using functions, macros, data types, etc. not documented in this
   manual is strongly discouraged.  If you do so your application is
   guaranteed to be incompatible with future versions of GMP.*
   
   * Menu:
   
   * Nomenclature and Types::              Which data types are there?
   * Function Classes::                    How the functions are organized.
   * GMP Variable Conventions::            Some rules and hints about variables.
   * GMP and Reentrancy::                  What about reentrancy?
   * Useful Macros and Constants::         Convenient helpers.
   * Compatibility with older versions::   Compatibility issues.
   * Getting the Latest Version of GMP::   How to get the software.
   
   
   File: gmp.info,  Node: Nomenclature and Types,  Next: Function Classes,  Prev: GMP Basics,  Up: GMP Basics
   
 Nomenclature and Types  Nomenclature and Types
 ======================  ======================
   
 In this manual, "integer" usually means a multiple precision integer, as  In this manual, "integer" usually means a multiple precision integer, as
 defined by the MP library.  The C data type for such integers is  defined by the GMP library.  The C data type for such integers is
 `mpz_t'.  Here are some examples of how to declare such integers:  `mpz_t'.  Here are some examples of how to declare such integers:
   
      mpz_t sum;       mpz_t sum;
Line 294  for these fractions is `mpq_t'.  For example:
Line 596  for these fractions is `mpq_t'.  For example:
      mpq_t quotient;       mpq_t quotient;
   
 "Floating point number" or "Float" for short, is an arbitrary precision  "Floating point number" or "Float" for short, is an arbitrary precision
 mantissa with an limited precision exponent.  The C data type for such  mantissa with a limited precision exponent.  The C data type for such
 objects is `mpf_t'.  objects is `mpf_t'.
   
 A "limb" means the part of a multi-precision number that fits in a  A "limb" means the part of a multi-precision number that fits in a
Line 303  analogous to a digit, only larger, and containing seve
Line 605  analogous to a digit, only larger, and containing seve
 Normally a limb contains 32 or 64 bits.  The C data type for a limb is  Normally a limb contains 32 or 64 bits.  The C data type for a limb is
 `mp_limb_t'.  `mp_limb_t'.
   
   
   File: gmp.info,  Node: Function Classes,  Next: GMP Variable Conventions,  Prev: Nomenclature and Types,  Up: GMP Basics
   
 Function Classes  Function Classes
 ================  ================
   
    There are six classes of functions in the MP library:     There are six classes of functions in the GMP library:
   
   1. Functions for signed integer arithmetic, with names beginning with    1. Functions for signed integer arithmetic, with names beginning with
      `mpz_'.  The associated type is `mpz_t'.  There are about 100       `mpz_'.  The associated type is `mpz_t'.  There are about 100
Line 322  Function Classes
Line 627  Function Classes
      `mpf_'.  The associated type is `mpf_t'.  There are about 50       `mpf_'.  The associated type is `mpf_t'.  There are about 50
      functions is this class.       functions is this class.
   
   4. Functions compatible with Berkeley MP, such as `itom', `madd', and    4. Functions compatible with Berkeley GMP, such as `itom', `madd', and
      `mult'.  The associated type is `MINT'.       `mult'.  The associated type is `MINT'.
   
   5. Fast low-level functions that operate on natural numbers.  These    5. Fast low-level functions that operate on natural numbers.  These
Line 334  Function Classes
Line 639  Function Classes
      The associated type is array of `mp_limb_t'.       The associated type is array of `mp_limb_t'.
   
   6. Miscellaneous functions.  Functions for setting up custom    6. Miscellaneous functions.  Functions for setting up custom
      allocation.       allocation and functions for generating random numbers.
   
 MP Variable Conventions  
 =======================  File: gmp.info,  Node: GMP Variable Conventions,  Next: GMP and Reentrancy,  Prev: Function Classes,  Up: GMP Basics
   
    As a general rule, all MP functions expect output arguments before  GMP Variable Conventions
   ========================
   
      As a general rule, all GMP functions expect output arguments before
 input arguments.  This notation is based on an analogy with the  input arguments.  This notation is based on an analogy with the
 assignment operator.  (The BSD MP compatibility functions disobey this  assignment operator.  (The BSD MP compatibility functions disobey this
 rule, having the output argument(s) last.)  rule, having the output argument(s) last.)
   
    MP allows you to use the same variable for both input and output in     GMP lets you use the same variable for both input and output in one
 the same expression.  For example, the main function for integer  call.  For example, the main function for integer multiplication,
 multiplication, `mpz_mul', can be used like this: `mpz_mul (x, x, x)'.  `mpz_mul', can be used to square `x' and put the result back in `x' with
 This computes the square of X and puts the result back in X.  
   
    Before you can assign to an MP variable, you need to initialize it       mpz_mul (x, x, x);
   
      Before you can assign to a GMP variable, you need to initialize it
 by calling one of the special initialization functions.  When you're  by calling one of the special initialization functions.  When you're
 done with a variable, you need to clear it out, using one of the  done with a variable, you need to clear it out, using one of the
 functions for that purpose.  Which function to use depends on the type  functions for that purpose.  Which function to use depends on the type
Line 360  functions, and floating-point functions for details.
Line 669  functions, and floating-point functions for details.
 between each initialization.  After a variable has been initialized, it  between each initialization.  After a variable has been initialized, it
 may be assigned to any number of times.  may be assigned to any number of times.
   
    For efficiency reasons, avoid to initialize and clear out a variable     For efficiency reasons, avoid initializing and clearing out a GMP
 in loops.  Instead, initialize it before entering the loop, and clear  variable in a loop.  Instead, initialize it before entering the loop,
 it out after the loop has exited.  and clear it out after the loop has exited.
   
    You don't need to be concerned about allocating additional space for     GMP variables are small, containing only a couple of sizes, and
 MP variables.  All functions in MP automatically allocate additional  pointers to allocated data.  Once you have initialized a GMP variable,
 space when a variable does not already have enough space.  They do not,  you don't need to worry about space allocation.  All functions in GMP
 however, reduce the space when a smaller number is stored in the  automatically allocate additional space when a variable does not
 object.  Most of the time, this policy is best, since it avoids  already have enough.  They do not, however, reduce the space when a
 frequent re-allocation.  smaller value is stored.  Most of the time this policy is best, since
   it avoids frequent re-allocation.
   
      When a variable of type `mpz_t' is used as a function parameter, it's
   effectively a call-by-reference, meaning anything the function does to
   it will be be done to the original in the caller.  When a function is
   going to return an `mpz_t' result, it should provide a separate
   parameter or parameters that it sets, like the GMP library functions
   do.  A `return' of an `mpz_t' doesn't return the object, only a pointer
   to it, and this is almost certainly not what you want.  All this
   applies to `mpq_t' and `mpf_t' too.
   
      Here's an example function accepting an `mpz_t' parameter, doing a
   certain calculation, and returning a result.
   
        void
        myfunction (mpz_t result, mpz_t param, unsigned long n)
        {
          unsigned long  i;
   
          mpz_mul_ui (result, param, n);
          for (i = 1; i < n; i++)
            mpz_add_ui (result, result, i*7);
        }
   
        int
        main (void)
        {
          mpz_t  r, n;
          mpz_init (r);
          mpz_init_set_str (n, "123456", 0);
   
          myfunction (r, n, 20L);
          mpz_out_str (stdout, 10, r); printf ("\n");
   
          return 0;
        }
   
      This example will work if `result' and `param' are the same
   variable, just like the library functions.  But sometimes this is
   tricky to arrange, and an application might not want to bother for its
   own subroutines.
   
      `mpz_t' is actually implemented as a one-element array of a certain
   structure type.  This is why using it to declare a variable gives an
   object with the fields GMP needs, but then using it as a parameter
   passes a pointer to the object.  Note that the actual contents of an
   `mpz_t' are for internal use only and you should not access them
   directly if you want your code to be compatible with future GMP
   releases.
   
   
   File: gmp.info,  Node: GMP and Reentrancy,  Next: Useful Macros and Constants,  Prev: GMP Variable Conventions,  Up: GMP Basics
   
   GMP and Reentrancy
   ==================
   
      The GMP code is reentrant and thread-safe, with some exceptions:
   
      * The function `mpf_set_default_prec' saves the selected precision in
        a global variable.
   
      * The function `mp_set_memory_functions' uses several global
        variables for storing the selected memory allocation functions.
   
      * If the memory allocation functions set by a call to
        `mp_set_memory_functions' (or `malloc' and friends by default) are
        not reentrant, GMP will not be reentrant either.
   
      * The old random number functions (`mpz_random', etc) use a random
        number generator from the C library, usually `mrand48' or
        `random'.  These routines are not reentrant, since they rely on
        global state.  (However the newer random number functions that
        accept a `gmp_randstate_t' parameter are reentrant.)
   
      * If `alloca' is not available, or GMP is configured with
        `--disable-alloca', the library is not reentrant, due to the
        current implementation of `stack-alloc.c'.  In the generated
        `config.h', `USE_STACK_ALLOC' set to 1 will mean not reentrant.
   
   
   File: gmp.info,  Node: Useful Macros and Constants,  Next: Compatibility with older versions,  Prev: GMP and Reentrancy,  Up: GMP Basics
   
 Useful Macros and Constants  Useful Macros and Constants
 ===========================  ===========================
   
Line 379  Useful Macros and Constants
Line 769  Useful Macros and Constants
   
  - Macro: __GNU_MP_VERSION   - Macro: __GNU_MP_VERSION
  - Macro: __GNU_MP_VERSION_MINOR   - Macro: __GNU_MP_VERSION_MINOR
      The major and minor MP version, respectively, as integers.   - Macro: __GNU_MP_VERSION_PATCHLEVEL
        The major and minor GMP version, and patch level, respectively, as
        integers.  For GMP i.j, these numbers will be i, j, and 0,
        respectively.  For GMP i.j.k, these numbers will be i, j, and k,
        respectively.
   
 Compatibility with Version 1.x  
 ==============================  File: gmp.info,  Node: Compatibility with older versions,  Next: Getting the Latest Version of GMP,  Prev: Useful Macros and Constants,  Up: GMP Basics
   
    This version of MP is upward compatible with previous versions of  Compatibility with older versions
 MP, with a few exceptions.  =================================
   
   1. Integer division functions round the result differently.  The old     This version of GMP is upwardly binary compatible with versions 3.0
      functions (`mpz_div', `mpz_divmod', `mpz_mdiv', `mpz_mdivmod',  and 3.0.1, and upwardly compatible at the source level with versions
      etc) now all use floor rounding (i.e., they round the quotient to  2.0, 2.0.1, and 2.0.2, with the following exceptions.
      -infinity).  There are a lot of new functions for integer  
      division, giving the user better control over the rounding.  
   
   2. The function `mpz_mod' now compute the true *mod* function.     * `mpn_gcd' had its source arguments swapped as of GMP 3.0 for
        consistency with other `mpn' functions.
   
   3. The functions `mpz_powm' and `mpz_powm_ui' now use *mod* for     * `mpf_get_prec' counted precision slightly differently in GMP 3.0
      reduction.       and 3.0.1, but in 3.1 has reverted to the 2.0.x style.
   
   4. The assignment functions for rational numbers do no longer  
      canonicalize their results.  In the case a non-canonical result  
      could arise from an assignment, the user need to insert an  
      explicit call to `mpq_canonicalize'.  This change was made for  
      efficiency.  
   
   5. Output generated by `mpz_out_raw' in this release cannot be read     There are a number of compatibility issues between GMP 1 and GMP 2
      by `mpz_inp_raw' in previous releases.  This change was made for  that of course also apply when porting applications from GMP 1 to GMP
      making the file format truly portable between machines with  3.  Please see the GMP 2 manual for details.
      different word sizes.  
   
   6. Several `mpn' functions have changed.  But they were intentionally  
      undocumented in previous releases.  File: gmp.info,  Node: Getting the Latest Version of GMP,  Prev: Compatibility with older versions,  Up: GMP Basics
   
   7. The functions `mpz_cmp_ui', `mpz_cmp_si', and `mpq_cmp_ui' are now  Getting the Latest Version of GMP
      implementated as macros, and thereby sometimes evaluate their  =================================
      arguments multiple times.  
   
   8. The functions `mpz_pow_ui' and `mpz_ui_pow_ui' now yield 1 for     The latest version of the GMP library is available at
      0^0.  (In version 1, they yielded 0.)  `ftp://ftp.gnu.org/pub/gnu/gmp'.  Many sites around the world mirror
   `ftp.gnu.org'; please use a mirror site near you, see
   `http://www.gnu.org/order/ftp.html'.
   
   
 Getting the Latest Version of MP  
 ================================  
   
    The latest version of the MP library is available by anonymous ftp  
 from from `prep.ai.mit.edu'.  The file name is  
 `/pub/gnu/gmp-M.N.tar.gz'.  Many sites around the world mirror `prep';  
 please use a mirror site near you.  
   
   
 File: gmp.info,  Node: Reporting Bugs,  Next: Integer Functions,  Prev: MP Basics,  Up: Top  File: gmp.info,  Node: Reporting Bugs,  Next: Integer Functions,  Prev: GMP Basics,  Up: Top
   
 Reporting Bugs  Reporting Bugs
 **************  **************
   
    If you think you have found a bug in the MP library, please     If you think you have found a bug in the GMP library, please
 investigate it and report it.  We have made this library available to  investigate it and report it.  We have made this library available to
 you, and it is not to ask too much from you, to ask you to report the  you, and it is not too much to ask you to report the bugs you find.
 bugs that you find.  Before you report a bug, you may want to check
   `http://www.swox.com/gmp/' for patches for this release.
   
    There are a few things you should think about when you put your bug     Please include the following in any report,
 report together.  
   
    You have to send us a test case that makes it possible for us to     * The GMP version number, and if pre-packaged or patched then say so.
 reproduce the bug.  Include instructions on how to run the test case.  
   
    You also have to explain what is wrong; if you get a crash, or if     * A test program that makes it possible for us to reproduce the bug.
 the results printed are incorrect and in that case, in what way.       Include instructions on how to run the program.
   
      * A description of what is wrong.  If the results are incorrect, in
        what way.  If you get a crash, say so.
   
      * If you get a crash, include a stack backtrace from the debugger if
        it's informative (`where' in `gdb', or `$C' in `adb').
   
      * *Please do not send core dumps, executables or `strace's.*
   
      * The configuration options you used when building GMP, if any.
   
      * The name of the compiler and its version.  For `gcc', get the
        version with `gcc -v', otherwise perhaps `what `which cc`', or
        similar.
   
      * The output from running `uname -a'.
   
      * The output from running `./config.guess'.
   
      * If the bug is related to `configure', then the contents of
        `config.log'.
   
      * If the bug is related to an `asm' file not assembling, then the
        contents of `config.m4'.
   
    It is not uncommon that an observed problem is actually due to a bug     It is not uncommon that an observed problem is actually due to a bug
 in the compiler used when building MP; the MP code tends to explore  in the compiler; the GMP code tends to explore interesting corners in
 interesting corners in compilers.  Therefore, please include compiler  compilers.
 version information in your bug report.  This can be extracted using  
 `what `which cc`', or, if you're using gcc, `gcc -v'.  Also, include  
 the output from `uname -a'.  
   
    If your bug report is good, we will do our best to help you to get a     If your bug report is good, we will do our best to help you get a
 corrected version of the library; if the bug report is poor, we won't  corrected version of the library; if the bug report is poor, we won't
 do anything about it (aside of chiding you to send better bug reports).  do anything about it (except maybe ask you to send a better report).
   
    Send your bug report to: `bug-gmp@prep.ai.mit.edu'.     Send your report to: <bug-gmp@gnu.org>.
   
    If you think something in this manual is unclear, or downright     If you think something in this manual is unclear, or downright
 incorrect, or if the language needs to be improved, please send a note  incorrect, or if the language needs to be improved, please send a note
Line 471  File: gmp.info,  Node: Integer Functions,  Next: Ratio
Line 870  File: gmp.info,  Node: Integer Functions,  Next: Ratio
 Integer Functions  Integer Functions
 *****************  *****************
   
    This chapter describes the MP functions for performing integer     This chapter describes the GMP functions for performing integer
 arithmetic.  These functions start with the prefix `mpz_'.  arithmetic.  These functions start with the prefix `mpz_'.
   
    Arbitrary precision integers are stored in objects of type `mpz_t'.     GMP integers are stored in objects of type `mpz_t'.
   
 * Menu:  * Menu:
   
Line 483  arithmetic.  These functions start with the prefix `mp
Line 882  arithmetic.  These functions start with the prefix `mp
 * Simultaneous Integer Init & Assign::  * Simultaneous Integer Init & Assign::
 * Converting Integers::  * Converting Integers::
 * Integer Arithmetic::  * Integer Arithmetic::
 * Comparison Functions::  * Integer Division::
   * Integer Exponentiation::
   * Integer Roots::
   * Number Theoretic Functions::
   * Integer Comparisons::
 * Integer Logic and Bit Fiddling::  * Integer Logic and Bit Fiddling::
 * I/O of Integers::  * I/O of Integers::
   * Integer Random Numbers::
 * Miscellaneous Integer Functions::  * Miscellaneous Integer Functions::
   
   
 File: gmp.info,  Node: Initializing Integers,  Next: Assigning Integers,  Up: Integer Functions  File: gmp.info,  Node: Initializing Integers,  Next: Assigning Integers,  Prev: Integer Functions,  Up: Integer Functions
   
 Initialization and Assignment Functions  Initialization Functions
 =======================================  ========================
   
    The functions for integer arithmetic assume that all integer objects     The functions for integer arithmetic assume that all integer objects
 are initialized.  You do that by calling the function `mpz_init'.  are initialized.  You do that by calling the function `mpz_init'.
Line 548  object is initialized.
Line 952  object is initialized.
 File: gmp.info,  Node: Assigning Integers,  Next: Simultaneous Integer Init & Assign,  Prev: Initializing Integers,  Up: Integer Functions  File: gmp.info,  Node: Assigning Integers,  Next: Simultaneous Integer Init & Assign,  Prev: Initializing Integers,  Up: Integer Functions
   
 Assignment Functions  Assignment Functions
 --------------------  ====================
   
    These functions assign new values to already initialized integers     These functions assign new values to already initialized integers
 (*note Initializing Integers::.).  (*note Initializing Integers::).
   
  - Function: void mpz_set (mpz_t ROP, mpz_t OP)   - Function: void mpz_set (mpz_t ROP, mpz_t OP)
  - Function: void mpz_set_ui (mpz_t ROP, unsigned long int OP)   - Function: void mpz_set_ui (mpz_t ROP, unsigned long int OP)
Line 573  Assignment Functions
Line 977  Assignment Functions
      This function returns 0 if the entire string up to the '\0' is a       This function returns 0 if the entire string up to the '\0' is a
      valid number in base BASE.  Otherwise it returns -1.       valid number in base BASE.  Otherwise it returns -1.
   
        [It turns out that it is not entirely true that this function
        ignores white-space.  It does ignore it between digits, but not
        after a minus sign or within or after "0x".  We are considering
        changing the definition of this function, making it fail when
        there is any white-space in the input, since that makes a lot of
        sense.  Please tell us your opinion about this change.  Do you
        really want it to accept "3 14" as meaning 314 as it does now?]
   
    - Function: void mpz_swap (mpz_t ROP1, mpz_t ROP2)
        Swap the values ROP1 and ROP2 efficiently.
   
   
 File: gmp.info,  Node: Simultaneous Integer Init & Assign,  Next: Converting Integers,  Prev: Assigning Integers,  Up: Integer Functions  File: gmp.info,  Node: Simultaneous Integer Init & Assign,  Next: Converting Integers,  Prev: Assigning Integers,  Up: Integer Functions
   
 Combined Initialization and Assignment Functions  Combined Initialization and Assignment Functions
 ------------------------------------------------  ================================================
   
    For convenience, MP provides a parallel series of initialize-and-set     For convenience, GMP provides a parallel series of
 functions which initialize the output and then store the value there.  initialize-and-set functions which initialize the output and then store
 These functions' names have the form `mpz_init_set...'  the value there.  These functions' names have the form `mpz_init_set...'
   
    Here is an example of using one:     Here is an example of using one:
   
Line 620  File: gmp.info,  Node: Converting Integers,  Next: Int
Line 1035  File: gmp.info,  Node: Converting Integers,  Next: Int
 Conversion Functions  Conversion Functions
 ====================  ====================
   
    This section describes functions for converting arbitrary precision     This section describes functions for converting GMP integers to
 integers to standard C types.  Functions for converting *to* arbitrary  standard C types.  Functions for converting _to_ GMP integers are
 precision integers are described in *Note Assigning Integers:: and  described in *Note Assigning Integers:: and *Note I/O of Integers::.
 *Note I/O of Integers::.  
   
    - Function: mp_limb_t mpz_getlimbn (mpz_t OP, mp_size_t N)
        Return limb #N from OP.  This function allows for very efficient
        decomposition of a number in its limbs.
   
        The function `mpz_size' can be used to determine the useful range
        for N.
   
  - Function: unsigned long int mpz_get_ui (mpz_t OP)   - Function: unsigned long int mpz_get_ui (mpz_t OP)
      Return the least significant part from OP.  This function combined       Return the least significant part from OP.  This function combined
      with       with
      `mpz_tdiv_q_2exp(..., OP, CHAR_BIT*sizeof(unsigned long int))' can       `mpz_tdiv_q_2exp(..., OP, CHAR_BIT*sizeof(unsigned long int))' can
      be used to extract the limbs of an integer.       be used to decompose an integer into unsigned longs.
   
  - Function: signed long int mpz_get_si (mpz_t OP)   - Function: signed long int mpz_get_si (mpz_t OP)
      If OP fits into a `signed long int' return the value of OP.       If OP fits into a `signed long int' return the value of OP.
Line 637  precision integers are described in *Note Assigning In
Line 1058  precision integers are described in *Note Assigning In
      sign as OP.       sign as OP.
   
      If OP is too large to fit in a `signed long int', the returned       If OP is too large to fit in a `signed long int', the returned
      result is probably not very useful.       result is probably not very useful.  To find out if the value will
        fit, use the function `mpz_fits_slong_p'.
   
  - Function: double mpz_get_d (mpz_t OP)   - Function: double mpz_get_d (mpz_t OP)
      Convert OP to a double.       Convert OP to a double.
Line 646  precision integers are described in *Note Assigning In
Line 1068  precision integers are described in *Note Assigning In
      Convert OP to a string of digits in base BASE.  The base may vary       Convert OP to a string of digits in base BASE.  The base may vary
      from 2 to 36.       from 2 to 36.
   
      If STR is NULL, space for the result string is allocated using the       If STR is `NULL', space for the result string is allocated using
      default allocation function, and a pointer to the string is       the default allocation function.
      returned.  
   
      If STR is not NULL, it should point to a block of storage enough       If STR is not `NULL', it should point to a block of storage enough
      large for the result.  To find out the right amount of space to       large for the result.  To find out the right amount of space to
      provide for STR, use `mpz_sizeinbase (OP, BASE) + 2'.  The two       provide for STR, use `mpz_sizeinbase (OP, BASE) + 2'.  The two
      extra bytes are for a possible minus sign, and for the terminating       extra bytes are for a possible minus sign, and for the terminating
      null character.       null character.
   
        A pointer to the result string is returned.  This pointer will
        will either equal STR, or if that is `NULL', will point to the
        allocated storage.
   
   
 File: gmp.info,  Node: Integer Arithmetic,  Next: Comparison Functions,  Prev: Converting Integers,  Up: Integer Functions  File: gmp.info,  Node: Integer Arithmetic,  Next: Integer Division,  Prev: Converting Integers,  Up: Integer Functions
   
 Arithmetic Functions  Arithmetic Functions
 ====================  ====================
Line 673  Arithmetic Functions
Line 1098  Arithmetic Functions
      Set ROP to OP1 - OP2.       Set ROP to OP1 - OP2.
   
  - Function: void mpz_mul (mpz_t ROP, mpz_t OP1, mpz_t OP2)   - Function: void mpz_mul (mpz_t ROP, mpz_t OP1, mpz_t OP2)
    - Function: void mpz_mul_si (mpz_t ROP, mpz_t OP1, long int OP2)
  - Function: void mpz_mul_ui (mpz_t ROP, mpz_t OP1, unsigned long int   - Function: void mpz_mul_ui (mpz_t ROP, mpz_t OP1, unsigned long int
           OP2)            OP2)
      Set ROP to OP1 times OP2.       Set ROP to OP1 times OP2.
   
    - Function: void mpz_addmul_ui (mpz_t ROP, mpz_t OP1, unsigned long
             int OP2)
        Add OP1 times OP2 to ROP.
   
  - Function: void mpz_mul_2exp (mpz_t ROP, mpz_t OP1, unsigned long int   - Function: void mpz_mul_2exp (mpz_t ROP, mpz_t OP1, unsigned long int
           OP2)            OP2)
      Set ROP to OP1 times 2 raised to OP2.  This operation can also be       Set ROP to OP1 times 2 raised to OP2.  This operation can also be
Line 687  Arithmetic Functions
Line 1117  Arithmetic Functions
   
  - Function: void mpz_abs (mpz_t ROP, mpz_t OP)   - Function: void mpz_abs (mpz_t ROP, mpz_t OP)
      Set ROP to the absolute value of OP.       Set ROP to the absolute value of OP.
   
  - Function: void mpz_fac_ui (mpz_t ROP, unsigned long int OP)  
      Set ROP to OP!, the factorial of OP.  
   
 Division functions  
 ------------------  
   
    Division is undefined if the divisor is zero, and passing a zero  
 divisor to the divide or modulo functions, as well passing a zero mod  
 argument to the `mpz_powm' and `mpz_powm_ui' functions, will make these  
 functions intentionally divide by zero.  This gives the user the  
 possibility to handle arithmetic exceptions in these functions in the  
 same manner as other arithmetic exceptions.  
   
    There are three main groups of division functions:  
    * Functions that truncate the quotient towards 0.  The names of these  
      functions start with `mpz_tdiv'.  The `t' in the name is short for  
      `truncate'.  
   
    * Functions that round the quotient towards -infinity.  The names of  
      these routines start with `mpz_fdiv'.  The `f' in the name is  
      short for `floor'.  
   
    * Functions that round the quotient towards +infinity.  The names of  
      these routines start with `mpz_cdiv'.  The `c' in the name is  
      short for `ceil'.  
   
    For each rounding mode, there are a couple of variants.  Here `q'  
 means that the quotient is computed, while `r' means that the remainder  
 is computed.  Functions that compute both the quotient and remainder  
 have `qr' in the name.  
   
  - Function: void mpz_tdiv_q (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
  - Function: void mpz_tdiv_q_ui (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Set ROP to [OP1/OP2].  The quotient is truncated towards 0.  
   
  - Function: void mpz_tdiv_r (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
  - Function: void mpz_tdiv_r_ui (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Set ROP to (OP1 - [OP1/OP2] * OP2).  Unless the remainder is zero,  
      it has the same sign as the dividend.  
   
  - Function: void mpz_tdiv_qr (mpz_t ROP1, mpz_t ROP2, mpz_t OP1, mpz_t  
           OP2)  
  - Function: void mpz_tdiv_qr_ui (mpz_t ROP1, mpz_t ROP2, mpz_t OP1,  
           unsigned long int OP2)  
      Divide OP1 by OP2 and put the quotient in ROP1 and the remainder  
      in ROP2.  The quotient is rounded towards 0.  Unless the remainder  
      is zero, it has the same sign as the dividend.  
   
      If ROP1 and ROP2 are the same variable, the results are undefined.  
   
  - Function: void mpz_fdiv_q (mpz_t ROP1, mpz_t OP1, mpz_t OP2)  
  - Function: void mpz_fdiv_q_ui (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Set ROP to OP1/OP2.  The quotient is rounded towards -infinity.  
   
  - Function: void mpz_fdiv_r (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
  - Function: unsigned long int mpz_fdiv_r_ui (mpz_t ROP, mpz_t OP1,  
           unsigned long int OP2)  
      Divide OP1 by OP2 and put the remainder in ROP.  Unless the  
      remainder is zero, it has the same sign as the divisor.  
   
      For `mpz_fdiv_r_ui' the remainder is small enough to fit in an  
      `unsigned long int', and is therefore returned.  
   
  - Function: void mpz_fdiv_qr (mpz_t ROP1, mpz_t ROP2, mpz_t OP1, mpz_t  
           OP2)  
  - Function: unsigned long int mpz_fdiv_qr_ui (mpz_t ROP1, mpz_t ROP2,  
           mpz_t OP1, unsigned long int OP2)  
      Divide OP1 by OP2 and put the quotient in ROP1 and the remainder  
      in ROP2.  The quotient is rounded towards -infinity.  Unless the  
      remainder is zero, it has the same sign as the divisor.  
   
      For `mpz_fdiv_qr_ui' the remainder is small enough to fit in an  
      `unsigned long int', and is therefore returned.  
   
      If ROP1 and ROP2 are the same variable, the results are undefined.  
   
  - Function: unsigned long int mpz_fdiv_ui (mpz_t OP1, unsigned long  
           int OP2)  
      This function is similar to `mpz_fdiv_r_ui', but the remainder is  
      only returned; it is not stored anywhere.  
   
  - Function: void mpz_cdiv_q (mpz_t ROP1, mpz_t OP1, mpz_t OP2)  
  - Function: void mpz_cdiv_q_ui (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Set ROP to OP1/OP2.  The quotient is rounded towards +infinity.  
   
  - Function: void mpz_cdiv_r (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
  - Function: unsigned long int mpz_cdiv_r_ui (mpz_t ROP, mpz_t OP1,  
           unsigned long int OP2)  
      Divide OP1 by OP2 and put the remainder in ROP.  Unless the  
      remainder is zero, it has the opposite sign as the divisor.  
   
      For `mpz_cdiv_r_ui' the negated remainder is small enough to fit  
      in an `unsigned long int', and it is therefore returned.  
   
  - Function: void mpz_cdiv_qr (mpz_t ROP1, mpz_t ROP2, mpz_t OP1, mpz_t  
           OP2)  
  - Function: unsigned long int mpz_cdiv_qr_ui (mpz_t ROP1, mpz_t ROP2,  
           mpz_t OP1, unsigned long int OP2)  
      Divide OP1 by OP2 and put the quotient in ROP1 and the remainder  
      in ROP2.  The quotient is rounded towards +infinity.  Unless the  
      remainder is zero, it has the opposite sign as the divisor.  
   
      For `mpz_cdiv_qr_ui' the negated remainder is small enough to fit  
      in an `unsigned long int', and it is therefore returned.  
   
      If ROP1 and ROP2 are the same variable, the results are undefined.  
   
  - Function: unsigned long int mpz_cdiv_ui (mpz_t OP1, unsigned long  
           int OP2)  
      Return the negated remainder, similar to `mpz_cdiv_r_ui'.  (The  
      difference is that this function doesn't store the remainder  
      anywhere.)  
   
  - Function: void mpz_mod (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
  - Function: unsigned long int mpz_mod_ui (mpz_t ROP, mpz_t OP1,  
           unsigned long int OP2)  
      Set ROP to OP1 `mod' OP2.  The sign of the divisor is ignored, and  
      the result is always non-negative.  
   
      For `mpz_mod_ui' the remainder is small enough to fit in an  
      `unsigned long int', and is therefore returned.  
   
  - Function: void mpz_divexact (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
      Set ROP to OP1/OP2.  This function produces correct results only  
      when it is known in advance that OP2 divides OP1.  
   
      Since mpz_divexact is much faster than any of the other routines  
      that produce the quotient (*note References::. Jebelean), it is  
      the best choice for instances in which exact division is known to  
      occur, such as reducing a rational to lowest terms.  
   
  - Function: void mpz_tdiv_q_2exp (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Set ROP to OP1 divided by 2 raised to OP2.  The quotient is  
      rounded towards 0.  
   
  - Function: void mpz_tdiv_r_2exp (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Divide OP1 by (2 raised to OP2) and put the remainder in ROP.  
      Unless it is zero, ROP will have the same sign as OP1.  
   
  - Function: void mpz_fdiv_q_2exp (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Set ROP to OP1 divided by 2 raised to OP2.  The quotient is  
      rounded towards -infinity.  
   
  - Function: void mpz_fdiv_r_2exp (mpz_t ROP, mpz_t OP1, unsigned long  
           int OP2)  
      Divide OP1 by (2 raised to OP2) and put the remainder in ROP.  The  
      sign of ROP will always be positive.  
   
      This operation can also be defined as masking of the OP2 least  
      significant bits.  
   
 Exponentialization Functions  
 ----------------------------  
   
  - Function: void mpz_powm (mpz_t ROP, mpz_t BASE, mpz_t EXP, mpz_t MOD)  
  - Function: void mpz_powm_ui (mpz_t ROP, mpz_t BASE, unsigned long int  
           EXP, mpz_t MOD)  
      Set ROP to (BASE raised to EXP) `mod' MOD.  If EXP is negative,  
      the result is undefined.  
   
  - Function: void mpz_pow_ui (mpz_t ROP, mpz_t BASE, unsigned long int  
           EXP)  
  - Function: void mpz_ui_pow_ui (mpz_t ROP, unsigned long int BASE,  
           unsigned long int EXP)  
      Set ROP to BASE raised to EXP.  The case of 0^0 yields 1.  
   
 Square Root Functions  
 ---------------------  
   
  - Function: void mpz_sqrt (mpz_t ROP, mpz_t OP)  
      Set ROP to the truncated integer part of the square root of OP.  
   
  - Function: void mpz_sqrtrem (mpz_t ROP1, mpz_t ROP2, mpz_t OP)  
      Set ROP1 to the truncated integer part of the square root of OP,  
      like `mpz_sqrt'.  Set ROP2 to OP-ROP1*ROP1, (i.e., zero if OP is a  
      perfect square).  
   
      If ROP1 and ROP2 are the same variable, the results are undefined.  
   
  - Function: int mpz_perfect_square_p (mpz_t OP)  
      Return non-zero if OP is a perfect square, i.e., if the square  
      root of OP is an integer.  Return zero otherwise.  
   
 Number Theoretic Functions  
 --------------------------  
   
  - Function: int mpz_probab_prime_p (mpz_t OP, int REPS)  
      If this function returns 0, OP is definitely not prime.  If it  
      returns 1, then OP is `probably' prime.  The probability of a  
      false positive is (1/4)**REPS.  A reasonable value of reps is 25.  
   
      An implementation of the probabilistic primality test found in  
      Seminumerical Algorithms (*note References::. Knuth).  
   
  - Function: void mpz_gcd (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
      Set ROP to the greatest common divisor of OP1 and OP2.  
   
  - Function: unsigned long int mpz_gcd_ui (mpz_t ROP, mpz_t OP1,  
           unsigned long int OP2)  
      Compute the greatest common divisor of OP1 and OP2.  If ROP is not  
      NULL, store the result there.  
   
      If the result is small enough to fit in an `unsigned long int', it  
      is returned.  If the result does not fit, 0 is returned, and the  
      result is equal to the argument OP1.  Note that the result will  
      always fit if OP2 is non-zero.  
   
  - Function: void mpz_gcdext (mpz_t G, mpz_t S, mpz_t T, mpz_t A, mpz_t  
           B)  
      Compute G, S, and T, such that AS + BT = G = `gcd' (A, B).  If T is  
      NULL, that argument is not computed.  
   
  - Function: int mpz_invert (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
      Compute the inverse of OP1 modulo OP2 and put the result in ROP.  
      Return non-zero if an inverse exist, zero otherwise.  When the  
      function returns zero, do not assume anything about the value in  
      ROP.  
   
  - Function: int mpz_jacobi (mpz_t OP1, mpz_t OP2)  
  - Function: int mpz_legendre (mpz_t OP1, mpz_t OP2)  
      Compute the Jacobi and Legendre symbols, respectively.  
   
   
 File: gmp.info,  Node: Comparison Functions,  Next: Integer Logic and Bit Fiddling,  Prev: Integer Arithmetic,  Up: Integer Functions  
   
 Comparison Functions  
 ====================  
   
  - Function: int mpz_cmp (mpz_t OP1, mpz_t OP2)  
      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero  
      if OP1 = OP2, and a negative value if OP1 < OP2.  
   
  - Macro: int mpz_cmp_ui (mpz_t OP1, unsigned long int OP2)  
  - Macro: int mpz_cmp_si (mpz_t OP1, signed long int OP2)  
      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero  
      if OP1 = OP2, and a negative value if OP1 < OP2.  
   
      These functions are actually implemented as macros.  They evaluate  
      their arguments multiple times.  
   
  - Macro: int mpz_sgn (mpz_t OP)  
      Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.  
   
      This function is actually implemented as a macro.  It evaluates its  
      arguments multiple times.  
   
   
 File: gmp.info,  Node: Integer Logic and Bit Fiddling,  Next: I/O of Integers,  Prev: Comparison Functions,  Up: Integer Functions  
   
 Logical and Bit Manipulation Functions  
 ======================================  
   
    These functions behave as if two's complement arithmetic were used  
 (although sign-magnitude is used by the actual implementation).  
   
  - Function: void mpz_and (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
      Set ROP to OP1 logical-and OP2.  
   
  - Function: void mpz_ior (mpz_t ROP, mpz_t OP1, mpz_t OP2)  
      Set ROP to OP1 inclusive-or OP2.  
   
  - Function: void mpz_com (mpz_t ROP, mpz_t OP)  
      Set ROP to the one's complement of OP.  
   
  - Function: unsigned long int mpz_popcount (mpz_t OP)  
      For non-negative numbers, return the population count of OP.  For  
      negative numbers, return the largest possible value (MAX_ULONG).  
   
  - Function: unsigned long int mpz_hamdist (mpz_t OP1, mpz_t OP2)  
      If OP1 and OP2 are both non-negative, return the hamming distance  
      between the two operands.  Otherwise, return the largest possible  
      value (MAX_ULONG).  
   
      It is possible to extend this function to return a useful value  
      when the operands are both negative, but the current  
      implementation returns MAX_ULONG in this case.  *Do not depend on  
      this behavior, since it will change in future versions of the  
      library.*  
   
  - Function: unsigned long int mpz_scan0 (mpz_t OP, unsigned long int  
           STARTING_BIT)  
      Scan OP, starting with bit STARTING_BIT, towards more significant  
      bits, until the first clear bit is found.  Return the index of the  
      found bit.  
   
  - Function: unsigned long int mpz_scan1 (mpz_t OP, unsigned long int  
           STARTING_BIT)  
      Scan OP, starting with bit STARTING_BIT, towards more significant  
      bits, until the first set bit is found.  Return the index of the  
      found bit.  
   
  - Function: void mpz_setbit (mpz_t ROP, unsigned long int BIT_INDEX)  
      Set bit BIT_INDEX in OP1.  
   
  - Function: void mpz_clrbit (mpz_t ROP, unsigned long int BIT_INDEX)  
      Clear bit BIT_INDEX in OP1.  
   
   
 File: gmp.info,  Node: I/O of Integers,  Next: Miscellaneous Integer Functions,  Prev: Integer Logic and Bit Fiddling,  Up: Integer Functions  
   
 Input and Output Functions  
 ==========================  
   
    Functions that perform input from a stdio stream, and functions that  
 output to a stdio stream.  Passing a NULL pointer for a STREAM argument  
 to any of these functions will make them read from `stdin' and write to  
 `stdout', respectively.  
   
    When using any of these functions, it is a good idea to include  
 `stdio.h' before `gmp.h', since that will allow `gmp.h' to define  
 prototypes for these functions.  
   
  - Function: size_t mpz_out_str (FILE *STREAM, int BASE, mpz_t OP)  
      Output OP on stdio stream STREAM, as a string of digits in base  
      BASE.  The base may vary from 2 to 36.  
   
      Return the number of bytes written, or if an error occurred,  
      return 0.  
   
  - Function: size_t mpz_inp_str (mpz_t ROP, FILE *STREAM, int BASE)  
      Input a possibly white-space preceded string in base BASE from  
      stdio stream STREAM, and put the read integer in ROP.  The base  
      may vary from 2 to 36.  If BASE is 0, the actual base is  
      determined from the leading characters: if the first two  
      characters are `0x' or `0X', hexadecimal is assumed, otherwise if  
      the first character is `0', octal is assumed, otherwise decimal is  
      assumed.  
   
      Return the number of bytes read, or if an error occurred, return 0.  
   
  - Function: size_t mpz_out_raw (FILE *STREAM, mpz_t OP)  
      Output OP on stdio stream STREAM, in raw binary format.  The  
      integer is written in a portable format, with 4 bytes of size  
      information, and that many bytes of limbs.  Both the size and the  
      limbs are written in decreasing significance order (i.e., in  
      big-endian).  
   
      The output can be read with `mpz_inp_raw'.  
   
      Return the number of bytes written, or if an error occurred,  
      return 0.  
   
      The output of this can not be read by `mpz_inp_raw' from GMP 1,  
      because of changes necessary for compatibility between 32-bit and  
      64-bit machines.  
   
  - Function: size_t mpz_inp_raw (mpz_t ROP, FILE *STREAM)  
      Input from stdio stream STREAM in the format written by  
      `mpz_out_raw', and put the result in ROP.  Return the number of  
      bytes read, or if an error occurred, return 0.  
   
      This routine can read the output from `mpz_out_raw' also from GMP  
      1, in spite of changes necessary for compatibility between 32-bit  
      and 64-bit machines.  
   
   
 File: gmp.info,  Node: Miscellaneous Integer Functions,  Prev: I/O of Integers,  Up: Integer Functions  
   
 Miscellaneous Functions  
 =======================  
   
  - Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE)  
      Generate a random integer of at most MAX_SIZE limbs.  The generated  
      random number doesn't satisfy any particular requirements of  
      randomness.  Negative random numbers are generated when MAX_SIZE  
      is negative.  
   
  - Function: void mpz_random2 (mpz_t ROP, mp_size_t MAX_SIZE)  
      Generate a random integer of at most MAX_SIZE limbs, with long  
      strings of zeros and ones in the binary representation.  Useful  
      for testing functions and algorithms, since this kind of random  
      numbers have proven to be more likely to trigger corner-case bugs.  
      Negative random numbers are generated when MAX_SIZE is negative.  
   
  - Function: size_t mpz_size (mpz_t OP)  
      Return the size of OP measured in number of limbs.  If OP is zero,  
      the returned value will be zero.  
   
      *This function is obsolete.  It will disappear from future MP  
      releases.*  
   
  - Function: size_t mpz_sizeinbase (mpz_t OP, int BASE)  
      Return the size of OP measured in number of digits in base BASE.  
      The base may vary from 2 to 36.  The returned value will be exact  
      or 1 too big.  If BASE is a power of 2, the returned value will  
      always be exact.  
   
      This function is useful in order to allocate the right amount of  
      space before converting OP to a string.  The right amount of  
      allocation is normally two more than the value returned by  
      `mpz_sizeinbase' (one extra for a minus sign and one for the  
      terminating '\0').  
   
   
 File: gmp.info,  Node: Rational Number Functions,  Next: Floating-point Functions,  Prev: Integer Functions,  Up: Top  
   
 Rational Number Functions  
 *************************  
   
    This chapter describes the MP functions for performing arithmetic on  
 rational numbers.  These functions start with the prefix `mpq_'.  
   
    Rational numbers are stored in objects of type `mpq_t'.  
   
    All rational arithmetic functions assume operands have a canonical  
 form, and canonicalize their result.  The canonical from means that the  
 denominator and the numerator have no common factors, and that the  
 denominator is positive.  Zero has the unique representation 0/1.  
   
    Pure assignment functions do not canonicalize the assigned variable.  
 It is the responsibility of the user to canonicalize the assigned  
 variable before any arithmetic operations are performed on that  
 variable.  *Note that this is an incompatible change from version 1 of  
 the library.*  
   
  - Function: void mpq_canonicalize (mpq_t OP)  
      Remove any factors that are common to the numerator and  
      denominator of OP, and make the denominator positive.  
   
 * Menu:  
   
 * Initializing Rationals::  
 * Assigning Rationals::  
 * Simultaneous Integer Init & Assign::  
 * Comparing Rationals::  
 * Applying Integer Functions::  
 * Miscellaneous Rational Functions::  
   
   
 File: gmp.info,  Node: Initializing Rationals,  Next: Assigning Rationals,  Prev: Rational Number Functions,  Up: Rational Number Functions  
   
 Initialization and Assignment Functions  
 =======================================  
   
  - Function: void mpq_init (mpq_t DEST_RATIONAL)  
      Initialize DEST_RATIONAL and set it to 0/1.  Each variable should  
      normally only be initialized once, or at least cleared out (using  
      the function `mpq_clear') between each initialization.  
   
  - Function: void mpq_clear (mpq_t RATIONAL_NUMBER)  
      Free the space occupied by RATIONAL_NUMBER.  Make sure to call this  
      function for all `mpq_t' variables when you are done with them.  
   
  - Function: void mpq_set (mpq_t ROP, mpq_t OP)  
  - Function: void mpq_set_z (mpq_t ROP, mpz_t OP)  
      Assign ROP from OP.  
   
  - Function: void mpq_set_ui (mpq_t ROP, unsigned long int OP1,  
           unsigned long int OP2)  
  - Function: void mpq_set_si (mpq_t ROP, signed long int OP1, unsigned  
           long int OP2)  
      Set the value of ROP to OP1/OP2.  Note that if OP1 and OP2 have  
      common factors, ROP has to be passed to `mpq_canonicalize' before  
      any operations are performed on ROP.  
   
   
 File: gmp.info,  Node: Assigning Rationals,  Next: Comparing Rationals,  Prev: Initializing Rationals,  Up: Rational Number Functions  
   
 Arithmetic Functions  
 ====================  
   
  - Function: void mpq_add (mpq_t SUM, mpq_t ADDEND1, mpq_t ADDEND2)  
      Set SUM to ADDEND1 + ADDEND2.  
   
  - Function: void mpq_sub (mpq_t DIFFERENCE, mpq_t MINUEND, mpq_t  
           SUBTRAHEND)  
      Set DIFFERENCE to MINUEND - SUBTRAHEND.  
   
  - Function: void mpq_mul (mpq_t PRODUCT, mpq_t MULTIPLIER, mpq_t  
           MULTIPLICAND)  
      Set PRODUCT to MULTIPLIER times MULTIPLICAND.  
   
  - Function: void mpq_div (mpq_t QUOTIENT, mpq_t DIVIDEND, mpq_t  
           DIVISOR)  
      Set QUOTIENT to DIVIDEND/DIVISOR.  
   
  - Function: void mpq_neg (mpq_t NEGATED_OPERAND, mpq_t OPERAND)  
      Set NEGATED_OPERAND to -OPERAND.  
   
  - Function: void mpq_inv (mpq_t INVERTED_NUMBER, mpq_t NUMBER)  
      Set INVERTED_NUMBER to 1/NUMBER.  If the new denominator is zero,  
      this routine will divide by zero.  
   
   
 File: gmp.info,  Node: Comparing Rationals,  Next: Applying Integer Functions,  Prev: Assigning Rationals,  Up: Rational Number Functions  
   
 Comparison Functions  
 ====================  
   
  - Function: int mpq_cmp (mpq_t OP1, mpq_t OP2)  
      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero  
      if OP1 = OP2, and a negative value if OP1 < OP2.  
   
      To determine if two rationals are equal, `mpq_equal' is faster than  
      `mpq_cmp'.  
   
  - Macro: int mpq_cmp_ui (mpq_t OP1, unsigned long int NUM2, unsigned  
           long int DEN2)  
      Compare OP1 and NUM2/DEN2.  Return a positive value if OP1 >  
      NUM2/DEN2, zero if OP1 = NUM2/DEN2, and a negative value if OP1 <  
      NUM2/DEN2.  
   
      This routine allows that NUM2 and DEN2 have common factors.  
   
      This function is actually implemented as a macro.  It evaluates its  
      arguments multiple times.  
   
  - Macro: int mpq_sgn (mpq_t OP)  
      Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.  
   
      This function is actually implemented as a macro.  It evaluates its  
      arguments multiple times.  
   
  - Function: int mpq_equal (mpq_t OP1, mpq_t OP2)  
      Return non-zero if OP1 and OP2 are equal, zero if they are  
      non-equal.  Although `mpq_cmp' can be used for the same purpose,  
      this function is much faster.  
   
   
 File: gmp.info,  Node: Applying Integer Functions,  Next: Miscellaneous Rational Functions,  Prev: Comparing Rationals,  Up: Rational Number Functions  
   
 Applying Integer Functions to Rationals  
 =======================================  
   
    The set of `mpq' functions is quite small.  In particular, there are  
 no functions for either input or output.  But there are two macros that  
 allow us to apply any `mpz' function on the numerator or denominator of  
 a rational number.  If these macros are used to assign to the rational  
 number, `mpq_canonicalize' normally need to be called afterwards.  
   
  - Macro: mpz_t mpq_numref (mpq_t OP)  
  - Macro: mpz_t mpq_denref (mpq_t OP)  
      Return a reference to the numerator and denominator of OP,  
      respectively.  The `mpz' functions can be used on the result of  
      these macros.  
   
   
 File: gmp.info,  Node: Miscellaneous Rational Functions,  Prev: Applying Integer Functions,  Up: Rational Number Functions  
   
 Miscellaneous Functions  
 =======================  
   
  - Function: double mpq_get_d (mpq_t OP)  
      Convert OP to a double.  
   
    These functions assign between either the numerator or denominator  
 of a rational, and an integer.  Instead of using these functions, it is  
 preferable to use the more general mechanisms `mpq_numref' and  
 `mpq_denref', together with `mpz_set'.  
   
  - Function: void mpq_set_num (mpq_t RATIONAL, mpz_t NUMERATOR)  
      Copy NUMERATOR to the numerator of RATIONAL.  When this risks to  
      make the numerator and denominator of RATIONAL have common  
      factors, you have to pass RATIONAL to `mpq_canonicalize' before  
      any operations are performed on RATIONAL.  
   
      This function is equivalent to `mpz_set (mpq_numref (RATIONAL),  
      NUMERATOR)'.  
   
  - Function: void mpq_set_den (mpq_t RATIONAL, mpz_t DENOMINATOR)  
      Copy DENOMINATOR to the denominator of RATIONAL.  When this risks  
      to make the numerator and denominator of RATIONAL have common  
      factors, or if the denominator might be negative, you have to pass  
      RATIONAL to `mpq_canonicalize' before any operations are performed  
      on RATIONAL.  
   
      *In version 1 of the library, negative denominators were handled by  
      copying the sign to the numerator.  That is no longer done.*  
   
      This function is equivalent to `mpz_set (mpq_denref (RATIONAL),  
      DENOMINATORS)'.  
   
  - Function: void mpq_get_num (mpz_t NUMERATOR, mpq_t RATIONAL)  
      Copy the numerator of RATIONAL to the integer NUMERATOR, to  
      prepare for integer operations on the numerator.  
   
      This function is equivalent to `mpz_set (NUMERATOR, mpq_numref  
      (RATIONAL))'.  
   
  - Function: void mpq_get_den (mpz_t DENOMINATOR, mpq_t RATIONAL)  
      Copy the denominator of RATIONAL to the integer DENOMINATOR, to  
      prepare for integer operations on the denominator.  
   
      This function is equivalent to `mpz_set (DENOMINATOR, mpq_denref  
      (RATIONAL))'.  
   

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>