version 1.1.1.1, 2000/01/10 15:35:26 |
version 1.1.1.2, 2000/09/09 14:13:04 |
Line 5 Copyright (C) 1995, 1996 Free Software Foundation, Inc |
|
Line 5 Copyright (C) 1995, 1996 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. */ |
|
|
unsigned normalization_steps; |
unsigned normalization_steps; |
mp_limb_t qlimb; |
mp_limb_t qlimb; |
#define N_QLIMBS (1 + (sizeof (double) + BYTES_PER_MP_LIMB-1) / BYTES_PER_MP_LIMB) |
#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); |
TMP_DECL (marker); |
|
|
if (nsize == 0) |
if (nsize == 0) |
|
|
{ |
{ |
double res; |
double res; |
mp_size_t i; |
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]; |
res = qp[qsize - 1]; |
for (i = qsize - 2; i >= 0; i--) |
for (i = qsize - 2; i >= 0; i--) |
res = res * MP_BASE_AS_DOUBLE + qp[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); |
TMP_FREE (marker); |
return sign_quotient >= 0 ? res : -res; |
return sign_quotient >= 0 ? res : -res; |