~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpz/tdiv_r_ui.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mpz_tdiv_r_ui(rem, dividend, divisor_limb)
2
2
   -- Set REM to DIVDEND mod DIVISOR_LIMB.
3
3
 
4
 
Copyright 1991, 1993, 1994, 1996, 1998, 2001, 2002 Free Software Foundation,
5
 
Inc.
 
4
Copyright 1991, 1993, 1994, 1996, 1998, 2001, 2002, 2004, 2005 Free Software
 
5
Foundation, Inc.
6
6
 
7
7
This file is part of the GNU MP Library.
8
8
 
18
18
 
19
19
You should have received a copy of the GNU Lesser General Public License
20
20
along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
21
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22
 
MA 02111-1307, USA. */
 
21
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
22
MA 02110-1301, USA. */
23
23
 
24
24
#include "gmp.h"
25
25
#include "gmp-impl.h"
43
43
 
44
44
  nn = ABS(ns);
45
45
  np = PTR(dividend);
46
 
#if GMP_NAIL_BITS != 0
 
46
#if BITS_PER_ULONG > GMP_NUMB_BITS  /* avoid warnings about shift amount */
47
47
  if (divisor > GMP_NUMB_MAX)
48
48
    {
49
49
      mp_limb_t dp[2];
50
50
      mp_ptr rp, qp;
51
51
      mp_size_t rn;
52
 
      TMP_DECL (mark);
 
52
      TMP_DECL;
53
53
 
54
54
      if (nn == 1)              /* tdiv_qr requirements; tested above for 0 */
55
55
        {
62
62
      MPZ_REALLOC (rem, 2);
63
63
      rp = PTR(rem);
64
64
 
65
 
      TMP_MARK (mark);
 
65
      TMP_MARK;
66
66
      dp[0] = divisor & GMP_NUMB_MASK;
67
67
      dp[1] = divisor >> GMP_NUMB_BITS;
68
68
      qp = TMP_ALLOC_LIMBS (nn - 2 + 1);
69
69
      mpn_tdiv_qr (qp, rp, (mp_size_t) 0, np, nn, dp, (mp_size_t) 2);
70
 
      TMP_FREE (mark);
 
70
      TMP_FREE;
71
71
      rl = rp[0] + (rp[1] << GMP_NUMB_BITS);
72
72
      rn = 2 - (rp[1] == 0);  rn -= (rp[rn - 1] == 0);
73
73
      SIZ(rem) = ns >= 0 ? rn : -rn;