summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2001-09-11 03:20:42 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2001-09-11 03:20:42 +0000
commit3ebba522c3a4e2e338e318a6315bd2c62947859e (patch)
tree5a5188c9776f2e92501f4abdd203de11ee22809e
parente8b8e6a47cde2cdc77d251359a63647b3103006b (diff)
downloadmpfr-3ebba522c3a4e2e338e318a6315bd2c62947859e.tar.gz
Macro MPFR_RET added. Ternary value for mpfr_set4.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1192 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--mpfr-impl.h3
-rw-r--r--mpfr.h2
-rw-r--r--set.c12
3 files changed, 12 insertions, 5 deletions
diff --git a/mpfr-impl.h b/mpfr-impl.h
index 43af5154d..1e79afcd9 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -86,6 +86,9 @@ typedef union ieee_double_extract Ieee_double_extract;
#define MPFR_SET_ZERO(x) \
(MPFR_MANT(x)[(MPFR_PREC(x)-1)/BITS_PER_MP_LIMB] = (mp_limb_t) 0)
+#define MPFR_RET(I) return \
+ ((I) ? (__mpfr_flags |= MPFR_FLAGS_INEXACT) : 0), (I)
+
/* Memory gestion */
/* temporary allocate s limbs at xp, and initialize mpfr variable x */
diff --git a/mpfr.h b/mpfr.h
index 88f2d414c..bbcad8ace 100644
--- a/mpfr.h
+++ b/mpfr.h
@@ -195,7 +195,7 @@ void mpfr_ceil _PROTO((mpfr_ptr, mpfr_srcptr));
void mpfr_extract _PROTO((mpz_ptr, mpfr_srcptr, unsigned int));
void mpfr_swap _PROTO((mpfr_ptr, mpfr_ptr));
void mpfr_dump _PROTO((mpfr_srcptr, mp_rnd_t));
-void mpfr_set4 _PROTO ((mpfr_ptr, mpfr_srcptr, mp_rnd_t, int));
+int mpfr_set4 _PROTO ((mpfr_ptr, mpfr_srcptr, mp_rnd_t, int));
int mpfr_cmp3 _PROTO ((mpfr_srcptr, mpfr_srcptr, int));
int mpfr_nan_p _PROTO((mpfr_srcptr));
int mpfr_inf_p _PROTO((mpfr_srcptr));
diff --git a/set.c b/set.c
index 754f53839..bb0b2e4ab 100644
--- a/set.c
+++ b/set.c
@@ -25,7 +25,7 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-impl.h"
-void
+int
#if __STDC__
mpfr_set4 (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode, int signb)
#else
@@ -36,17 +36,20 @@ mpfr_set4 (a, b, rnd_mode, signb)
int signb;
#endif
{
+ int inex;
+
if (MPFR_IS_NAN(b))
{
MPFR_CLEAR_FLAGS(a);
MPFR_SET_NAN(a);
- return;
+ MPFR_RET(0);
}
if (MPFR_IS_INF(b))
{
MPFR_CLEAR_FLAGS(a);
MPFR_SET_INF(a);
+ inex = 0;
}
else
{
@@ -60,7 +63,7 @@ mpfr_set4 (a, b, rnd_mode, signb)
aq = MPFR_PREC(a);
carry = mpfr_round_raw(ap, MPFR_MANT(b), MPFR_PREC(b), (signb < 0),
- aq, rnd_mode, NULL);
+ aq, rnd_mode, &inex);
MPFR_EXP(a) = MPFR_EXP(b);
if (carry)
@@ -69,7 +72,7 @@ mpfr_set4 (a, b, rnd_mode, signb)
if (exp == __mpfr_emax)
{
mpfr_set_overflow(a, rnd_mode, signb);
- return;
+ MPFR_RET(inex);
}
else
{
@@ -80,4 +83,5 @@ mpfr_set4 (a, b, rnd_mode, signb)
}
if (MPFR_SIGN(a) * signb < 0) MPFR_CHANGE_SIGN(a);
+ MPFR_RET(inex);
}