Annotation of OpenXM_contrib/gmp/mpn/generic/divrem_1.c, Revision 1.1
1.1 ! maekawa 1: /* mpn_divrem_1(quot_ptr, qsize, dividend_ptr, dividend_size, divisor_limb) --
! 2: Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
! 3: Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR.
! 4: Return the single-limb remainder.
! 5: There are no constraints on the value of the divisor.
! 6:
! 7: QUOT_PTR and DIVIDEND_PTR might point to the same limb.
! 8:
! 9: Copyright (C) 1996 Free Software Foundation, Inc.
! 10:
! 11: This file is part of the GNU MP Library.
! 12:
! 13: The GNU MP Library is free software; you can redistribute it and/or modify
! 14: it under the terms of the GNU Library General Public License as published by
! 15: the Free Software Foundation; either version 2 of the License, or (at your
! 16: option) any later version.
! 17:
! 18: The GNU MP Library is distributed in the hope that it will be useful, but
! 19: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 20: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
! 21: License for more details.
! 22:
! 23: You should have received a copy of the GNU Library General Public License
! 24: along with the GNU MP Library; see the file COPYING.LIB. If not, write to
! 25: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
! 26: MA 02111-1307, USA. */
! 27:
! 28: #include "gmp.h"
! 29: #include "gmp-impl.h"
! 30: #include "longlong.h"
! 31:
! 32: mp_limb_t
! 33: #if __STDC__
! 34: mpn_divrem_1 (mp_ptr qp, mp_size_t qsize,
! 35: mp_srcptr dividend_ptr, mp_size_t dividend_size,
! 36: mp_limb_t divisor_limb)
! 37: #else
! 38: mpn_divrem_1 (qp, qsize, dividend_ptr, dividend_size, divisor_limb)
! 39: mp_ptr qp;
! 40: mp_size_t qsize;
! 41: mp_srcptr dividend_ptr;
! 42: mp_size_t dividend_size;
! 43: mp_limb_t divisor_limb;
! 44: #endif
! 45: {
! 46: mp_limb_t rlimb;
! 47: long i;
! 48:
! 49: /* Develop integer part of quotient. */
! 50: rlimb = mpn_divmod_1 (qp + qsize, dividend_ptr, dividend_size, divisor_limb);
! 51:
! 52: if (qsize != 0)
! 53: {
! 54: for (i = qsize - 1; i >= 0; i--)
! 55: udiv_qrnnd (qp[i], rlimb, rlimb, 0, divisor_limb);
! 56: }
! 57: return rlimb;
! 58: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>