version 1.1.1.1, 2000/01/10 15:35:23 |
version 1.1.1.2, 2000/09/09 14:12:26 |
|
|
Return the single-limb remainder. |
Return the single-limb remainder. |
There are no constraints on the value of the divisor. |
There are no constraints on the value of the divisor. |
|
|
Copyright (C) 1991, 1993, 1994, Free Software Foundation, Inc. |
Copyright (C) 1991, 1993, 1994, 1999 Free Software Foundation, Inc. |
|
|
This file is part of the GNU MP Library. |
This file is part of the GNU MP Library. |
|
|
The GNU MP Library is free software; you can redistribute it and/or modify |
The GNU MP Library is free software; you can redistribute it and/or modify |
it under the terms of the GNU Library General Public License as published by |
it under the terms of the GNU Lesser General Public License as published by |
the Free Software Foundation; either version 2 of the License, or (at your |
the Free Software Foundation; either version 2.1 of the License, or (at your |
option) any later version. |
option) any later version. |
|
|
The GNU MP Library is distributed in the hope that it will be useful, but |
The GNU MP Library is distributed in the hope that it will be useful, but |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
License for more details. |
License for more details. |
|
|
You should have received a copy of the GNU Library General Public License |
You should have received a copy of the GNU Lesser General Public License |
along with the GNU MP Library; see the file COPYING.LIB. If not, write to |
along with the GNU MP Library; see the file COPYING.LIB. If not, write to |
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
MA 02111-1307, USA. */ |
MA 02111-1307, USA. */ |
Line 34 MA 02111-1307, USA. */ |
|
Line 34 MA 02111-1307, USA. */ |
|
#define UDIV_TIME UMUL_TIME |
#define UDIV_TIME UMUL_TIME |
#endif |
#endif |
|
|
/* FIXME: We should be using invert_limb (or invert_normalized_limb) |
|
here (not udiv_qrnnd). */ |
|
|
|
mp_limb_t |
mp_limb_t |
#if __STDC__ |
#if __STDC__ |
mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size, |
mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size, |
Line 74 mpn_mod_1 (dividend_ptr, dividend_size, divisor_limb) |
|
Line 71 mpn_mod_1 (dividend_ptr, dividend_size, divisor_limb) |
|
mp_limb_t divisor_limb_inverted; |
mp_limb_t divisor_limb_inverted; |
|
|
divisor_limb <<= normalization_steps; |
divisor_limb <<= normalization_steps; |
|
invert_limb (divisor_limb_inverted, divisor_limb); |
|
|
/* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The |
|
result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the |
|
most significant bit (with weight 2**N) implicit. */ |
|
|
|
/* Special case for DIVISOR_LIMB == 100...000. */ |
|
if (divisor_limb << 1 == 0) |
|
divisor_limb_inverted = ~(mp_limb_t) 0; |
|
else |
|
udiv_qrnnd (divisor_limb_inverted, dummy, |
|
-divisor_limb, 0, divisor_limb); |
|
|
|
n1 = dividend_ptr[dividend_size - 1]; |
n1 = dividend_ptr[dividend_size - 1]; |
r = n1 >> (BITS_PER_MP_LIMB - normalization_steps); |
r = n1 >> (BITS_PER_MP_LIMB - normalization_steps); |
|
|
Line 113 mpn_mod_1 (dividend_ptr, dividend_size, divisor_limb) |
|
Line 100 mpn_mod_1 (dividend_ptr, dividend_size, divisor_limb) |
|
{ |
{ |
mp_limb_t divisor_limb_inverted; |
mp_limb_t divisor_limb_inverted; |
|
|
/* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The |
invert_limb (divisor_limb_inverted, divisor_limb); |
result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the |
|
most significant bit (with weight 2**N) implicit. */ |
|
|
|
/* Special case for DIVISOR_LIMB == 100...000. */ |
|
if (divisor_limb << 1 == 0) |
|
divisor_limb_inverted = ~(mp_limb_t) 0; |
|
else |
|
udiv_qrnnd (divisor_limb_inverted, dummy, |
|
-divisor_limb, 0, divisor_limb); |
|
|
|
i = dividend_size - 1; |
i = dividend_size - 1; |
r = dividend_ptr[i]; |
r = dividend_ptr[i]; |