version 1.1.1.2, 2000/09/09 14:12:55 |
version 1.1.1.3, 2003/08/25 16:06:33 |
|
|
/* mpz_mul_2exp -- Multiply a bignum by 2**CNT |
/* mpz_mul_2exp -- Multiply a bignum by 2**CNT |
|
|
Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc. |
Copyright 1991, 1993, 1994, 1996, 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 23 MA 02111-1307, USA. */ |
|
Line 23 MA 02111-1307, USA. */ |
|
#include "gmp-impl.h" |
#include "gmp-impl.h" |
|
|
void |
void |
#if __STDC__ |
|
mpz_mul_2exp (mpz_ptr w, mpz_srcptr u, unsigned long int cnt) |
mpz_mul_2exp (mpz_ptr w, mpz_srcptr u, unsigned long int cnt) |
#else |
|
mpz_mul_2exp (w, u, cnt) |
|
mpz_ptr w; |
|
mpz_srcptr u; |
|
unsigned long int cnt; |
|
#endif |
|
{ |
{ |
mp_size_t usize = u->_mp_size; |
mp_size_t usize = u->_mp_size; |
mp_size_t abs_usize = ABS (usize); |
mp_size_t abs_usize = ABS (usize); |
Line 45 mpz_mul_2exp (w, u, cnt) |
|
Line 38 mpz_mul_2exp (w, u, cnt) |
|
return; |
return; |
} |
} |
|
|
limb_cnt = cnt / BITS_PER_MP_LIMB; |
limb_cnt = cnt / GMP_NUMB_BITS; |
wsize = abs_usize + limb_cnt + 1; |
wsize = abs_usize + limb_cnt + 1; |
if (w->_mp_alloc < wsize) |
if (w->_mp_alloc < wsize) |
_mpz_realloc (w, wsize); |
_mpz_realloc (w, wsize); |
Line 53 mpz_mul_2exp (w, u, cnt) |
|
Line 46 mpz_mul_2exp (w, u, cnt) |
|
wp = w->_mp_d; |
wp = w->_mp_d; |
wsize = abs_usize + limb_cnt; |
wsize = abs_usize + limb_cnt; |
|
|
cnt %= BITS_PER_MP_LIMB; |
cnt %= GMP_NUMB_BITS; |
if (cnt != 0) |
if (cnt != 0) |
{ |
{ |
wlimb = mpn_lshift (wp + limb_cnt, u->_mp_d, abs_usize, cnt); |
wlimb = mpn_lshift (wp + limb_cnt, u->_mp_d, abs_usize, cnt); |