=================================================================== RCS file: /home/cvs/OpenXM_contrib/gmp/mpq/Attic/get_d.c,v retrieving revision 1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1 -r1.1.1.2 --- OpenXM_contrib/gmp/mpq/Attic/get_d.c 2000/01/10 15:35:26 1.1 +++ OpenXM_contrib/gmp/mpq/Attic/get_d.c 2000/09/09 14:13:04 1.1.1.2 @@ -5,16 +5,16 @@ Copyright (C) 1995, 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 +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 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 +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 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 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -65,7 +65,8 @@ mpq_get_d (src) unsigned normalization_steps; mp_limb_t qlimb; #define N_QLIMBS (1 + (sizeof (double) + BYTES_PER_MP_LIMB-1) / BYTES_PER_MP_LIMB) - mp_limb_t qp[N_QLIMBS + 1]; + mp_limb_t qarr[N_QLIMBS + 1]; + mp_ptr qp = qarr; TMP_DECL (marker); if (nsize == 0) @@ -138,12 +139,25 @@ mpq_get_d (src) { double res; mp_size_t i; + int scale = nsize - dsize - N_QLIMBS; +#if defined (__vax__) + /* Ignore excess quotient limbs. This is necessary on a vax + with its small double exponent, since we'd otherwise get + exponent overflow while forming RES. */ + if (qsize > N_QLIMBS) + { + qp += qsize - N_QLIMBS; + scale += qsize - N_QLIMBS; + qsize = N_QLIMBS; + } +#endif + res = qp[qsize - 1]; for (i = qsize - 2; i >= 0; i--) res = res * MP_BASE_AS_DOUBLE + qp[i]; - res = __gmp_scale2 (res, BITS_PER_MP_LIMB * (nsize - dsize - N_QLIMBS)); + res = __gmp_scale2 (res, BITS_PER_MP_LIMB * scale); TMP_FREE (marker); return sign_quotient >= 0 ? res : -res;