DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gmp.info.gz) Initializing Integers

Info Catalog (gmp.info.gz) Integer Functions (gmp.info.gz) Integer Functions (gmp.info.gz) Assigning Integers
 
 Initialization Functions
 ========================
 
 The functions for integer arithmetic assume that all integer objects are
 initialized.  You do that by calling the function `mpz_init'.  For
 example,
 
      {
        mpz_t integ;
        mpz_init (integ);
        ...
        mpz_add (integ, ...);
        ...
        mpz_sub (integ, ...);
      
        /* Unless the program is about to exit, do ... */
        mpz_clear (integ);
      }
 
    As you can see, you can store new values any number of times, once an
 object is initialized.
 
  - Function: void mpz_init (mpz_t INTEGER)
      Initialize INTEGER, and set its value to 0.
 
  - Function: void mpz_init2 (mpz_t INTEGER, unsigned long N)
      Initialize INTEGER, with space for N bits, and set its value to 0.
 
      N is only the initial space, INTEGER will grow automatically in
      the normal way, if necessary, for subsequent values stored.
      `mpz_init2' makes it possible to avoid such reallocations if a
      maximum size is known in advance.
 
  - Function: void mpz_clear (mpz_t INTEGER)
      Free the space occupied by INTEGER.  Call this function for all
      `mpz_t' variables when you are done with them.
 
  - Function: void mpz_realloc2 (mpz_t INTEGER, unsigned long N)
      Change the space allocated for INTEGER to N bits.  The value in
      INTEGER is preserved if it fits, or is set to 0 if not.
 
      This function can be used to increase the space for a variable in
      order to avoid repeated automatic reallocations, or to decrease it
      to give memory back to the heap.
 
Info Catalog (gmp.info.gz) Integer Functions (gmp.info.gz) Integer Functions (gmp.info.gz) Assigning Integers
automatically generated byinfo2html