summaryrefslogtreecommitdiff
path: root/init2.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-27 15:15:04 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-27 15:15:04 +0000
commit734c0a144b04e2cae4e67b394010e3f6e3cadecc (patch)
treee0bb801e56a43c3aebe1ad73851ede3588e082fb /init2.c
parenta7f45009dff2e3d0e8698b44e45f5cacacb82cdd (diff)
downloadmpfr-734c0a144b04e2cae4e67b394010e3f6e3cadecc.tar.gz
Change the internal format of MPFR: ZERO, INF and NAN have special values of exp.
Rename MPFR_ESIZE in MPFR_LIMB_SIZE. Rename MPFR_ABSZISE in MPFR_ALLOC_SIZE. Rename MPFR_INIT in MPFR_TMP_INIT (INIT1 too). "mpfr.h" includes <gmp.h> if GMP isn't detected. Change the way of detecting stdio.h (To check). Use mpfr namespace for new definitions in "mpfr.h". git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2524 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'init2.c')
-rw-r--r--init2.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/init2.c b/init2.c
index fd76177a5..676f7daff 100644
--- a/init2.c
+++ b/init2.c
@@ -26,9 +26,10 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
void
-mpfr_init2 (mpfr_ptr x, mp_prec_t p)
+mpfr_init2 (mpfr_ptr x, mpfr_prec_t p)
{
- mp_size_t xsize;
+ mpfr_size_t xsize;
+ mp_ptr tmp;
/* p=1 is not allowed since the rounding to nearest even rule requires at
least two bits of mantissa: the neighbours of 3/2 are 1*2^0 and 1*2^1,
@@ -36,10 +37,11 @@ mpfr_init2 (mpfr_ptr x, mp_prec_t p)
MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX);
xsize = (mp_size_t) ((p - 1) / BITS_PER_MP_LIMB) + 1;
-
+ tmp = (mp_ptr) (*__gmp_allocate_func)(MPFR_ALLOC_SIZE(xsize));
+
MPFR_PREC(x) = p;
- MPFR_MANT(x) = (mp_ptr)
- (*__gmp_allocate_func) ((size_t) xsize * BYTES_PER_MP_LIMB);
- MPFR_SIZE(x) = xsize;
+ MPFR_SET_POS(x); /* Set a sign */
+ MPFR_SET_MANT_PTR(x, tmp);
+ MPFR_SET_ALLOC_SIZE(x, xsize);
MPFR_SET_NAN(x); /* initializes to NaN */
}