summaryrefslogtreecommitdiff
path: root/mpfr/set_prec.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-03-09 23:49:20 +0100
committerKevin Ryde <user42@zip.com.au>2002-03-09 23:49:20 +0100
commit5548ebac58434a675c5c9daa25dbc1fe572beb0c (patch)
tree6a9e6f49e2f25c7401b64946fdf055bf8b2e965d /mpfr/set_prec.c
parent9262a18b652b66e71b8fd0fb84f77e3c8588e21c (diff)
downloadgmp-5548ebac58434a675c5c9daa25dbc1fe572beb0c.tar.gz
* mpfr: Update to 20020301, except internal_ceil_exp2.c,
internal_ceil_log2.c, internal_floor_log2.c renamed to i_ceil_exp2.c, i_ceil_log2.c, i_floor_log2.c to be unique in DOS 8.3. And sqrtrem.c removed since no longer required.
Diffstat (limited to 'mpfr/set_prec.c')
-rw-r--r--mpfr/set_prec.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/mpfr/set_prec.c b/mpfr/set_prec.c
index ebee34ed2..f6591c0f2 100644
--- a/mpfr/set_prec.c
+++ b/mpfr/set_prec.c
@@ -20,7 +20,6 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
-#include <stdlib.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
@@ -29,20 +28,22 @@ MA 02111-1307, USA. */
int
mpfr_set_prec (mpfr_ptr x, mp_prec_t p)
{
- mp_prec_t xsize;
+ mp_size_t xsize;
- if (p == 0)
- return 1;
+ MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX);
- xsize = (p - 1)/BITS_PER_MP_LIMB + 1; /* new limb size */
+ xsize = (p - 1) / BITS_PER_MP_LIMB + 1; /* new limb size */
- if (xsize > MPFR_ABSSIZE(x)) {
- MPFR_MANT(x) = (mp_ptr) (*__gmp_reallocate_func) (MPFR_MANT(x),
- MPFR_ABSSIZE(x)*BYTES_PER_MP_LIMB, xsize * BYTES_PER_MP_LIMB);
- MPFR_SIZE(x) = xsize; /* new number of allocated limbs */
- }
+ if (xsize > MPFR_ABSSIZE(x))
+ {
+ MPFR_MANT(x) = (mp_ptr) (*__gmp_reallocate_func)
+ (MPFR_MANT(x), (size_t) MPFR_ABSSIZE(x) * BYTES_PER_MP_LIMB,
+ (size_t) xsize * BYTES_PER_MP_LIMB);
+ MPFR_SIZE(x) = xsize; /* new number of allocated limbs */
+ }
MPFR_PREC(x) = p;
+ MPFR_SET_NAN(x); /* initializes to NaN */
return MPFR_MANT(x) == NULL;
}