[BACK]Return to divrem_1.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpn / generic

File: [local] / OpenXM_contrib / gmp / mpn / generic / Attic / divrem_1.c (download)

Revision 1.1.1.1 (vendor branch), Mon Jan 10 15:35:23 2000 UTC (24 years, 5 months ago) by maekawa
Branch: GMP
CVS Tags: VERSION_2_0_2, RELEASE_20000124, RELEASE_1_1_2
Changes since 1.1: +0 -0 lines

Import gmp 2.0.2

/* mpn_divrem_1(quot_ptr, qsize, dividend_ptr, dividend_size, divisor_limb) --
   Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
   Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR.
   Return the single-limb remainder.
   There are no constraints on the value of the divisor.

   QUOT_PTR and DIVIDEND_PTR might point to the same limb.

Copyright (C) 1996 Free Software Foundation, Inc.

This file is part of the GNU MP Library.

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
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

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
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
License for more details.

You should have received a copy of the GNU Library General Public License
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,
MA 02111-1307, USA. */

#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"

mp_limb_t
#if __STDC__
mpn_divrem_1 (mp_ptr qp, mp_size_t qsize,
	      mp_srcptr dividend_ptr, mp_size_t dividend_size,
	      mp_limb_t divisor_limb)
#else
mpn_divrem_1 (qp, qsize, dividend_ptr, dividend_size, divisor_limb)
     mp_ptr qp;
     mp_size_t qsize;
     mp_srcptr dividend_ptr;
     mp_size_t dividend_size;
     mp_limb_t divisor_limb;
#endif
{
  mp_limb_t rlimb;
  long i;

  /* Develop integer part of quotient.  */
  rlimb = mpn_divmod_1 (qp + qsize, dividend_ptr, dividend_size, divisor_limb);

  if (qsize != 0)
    {
      for (i = qsize - 1; i >= 0; i--)
	udiv_qrnnd (qp[i], rlimb, rlimb, 0, divisor_limb);
    }
  return rlimb;
}