[BACK]Return to urandomb.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpf

Diff for /OpenXM_contrib/gmp/mpf/Attic/urandomb.c between version 1.1 and 1.1.1.2

version 1.1, 2000/09/09 14:13:15 version 1.1.1.2, 2003/08/25 16:06:35
Line 3 
Line 3 
    using STATE as the random state previously initialized by a call to     using STATE as the random state previously initialized by a call to
    gmp_randinit().     gmp_randinit().
   
 Copyright (C) 1999, 2000  Free Software Foundation, Inc.  Copyright 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
   
 This file is part of the GNU MP Library.  This file is part of the GNU MP Library.
   
Line 26  MA 02111-1307, USA. */
Line 26  MA 02111-1307, USA. */
 #include "gmp-impl.h"  #include "gmp-impl.h"
   
 void  void
 #if __STDC__  
 mpf_urandomb (mpf_t rop, gmp_randstate_t rstate, unsigned long int nbits)  mpf_urandomb (mpf_t rop, gmp_randstate_t rstate, unsigned long int nbits)
 #else  
 mpf_urandomb (rop, rstate, nbits)  
      mpf_t rop;  
      gmp_randstate_t rstate;  
      unsigned long int nbits;  
 #endif  
 {  {
   mp_ptr rp;    mp_ptr rp;
   mp_size_t nlimbs;    mp_size_t nlimbs;
   mp_exp_t exp;    mp_exp_t exp;
   
     nbits = MIN (nbits, __GMPF_PREC_TO_BITS (rop->_mp_prec));
   
   rp = PTR (rop);    rp = PTR (rop);
   nlimbs = (nbits + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB;    nlimbs = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
   
   _gmp_rand (rp, rstate, nbits);    _gmp_rand (rp, rstate, nbits);
   
   /* If nbits isn't a multiple of BITS_PER_MP_LIMB, shift up.  */    /* If nbits isn't a multiple of GMP_NUMB_BITS, shift up.  */
   if (nlimbs != 0)    if (nlimbs != 0)
     {      {
       if (nbits % BITS_PER_MP_LIMB != 0)        if (nbits % GMP_NUMB_BITS != 0)
         mpn_lshift (rp, rp, nlimbs,          mpn_lshift (rp, rp, nlimbs, GMP_NUMB_BITS - nbits % GMP_NUMB_BITS);
                     BITS_PER_MP_LIMB - nbits % BITS_PER_MP_LIMB);  
     }      }
   
   exp = 0;    exp = 0;
Line 60  mpf_urandomb (rop, rstate, nbits)
Line 54  mpf_urandomb (rop, rstate, nbits)
     }      }
   EXP (rop) = exp;    EXP (rop) = exp;
   SIZ (rop) = nlimbs;    SIZ (rop) = nlimbs;
   
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.1.2

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