summaryrefslogtreecommitdiff
path: root/add_ui.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-10-19 16:26:19 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-10-19 16:26:19 +0000
commit8c9c4dfd891f9b0054bb239dcba4ea04a1661cfd (patch)
tree4237d98d3f0ed4dbda98e8b38c09cc6f30fa4286 /add_ui.c
parent5828fb39ddf84fe23e20f14f15ec1e1e243f6007 (diff)
downloadmpfr-8c9c4dfd891f9b0054bb239dcba4ea04a1661cfd.tar.gz
added ternary flag
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1320 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'add_ui.c')
-rw-r--r--add_ui.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/add_ui.c b/add_ui.c
index 3854d3efb..0e1ebbe5c 100644
--- a/add_ui.c
+++ b/add_ui.c
@@ -1,6 +1,6 @@
/* mpfr_add_ui -- add a floating-point number with a machine integer
-Copyright (C) 2000 Free Software Foundation.
+Copyright (C) 2000-2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -26,7 +26,7 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-impl.h"
-void
+int
#if __STDC__
mpfr_add_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
#else
@@ -40,20 +40,23 @@ mpfr_add_ui (y, x, u, rnd_mode)
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
-
- if (u) { /* if u=0, do nothing */
- MPFR_INIT1(up, uu, BITS_PER_MP_LIMB, 1);
- count_leading_zeros(cnt, (mp_limb_t) u);
- *up = (mp_limb_t) u << cnt;
- MPFR_EXP(uu) = BITS_PER_MP_LIMB-cnt;
-
- /* Optimization note: Exponent operations may be removed
- if mpfr_add works even when uu is out-of-range. */
- mpfr_save_emin_emax();
- mpfr_add(y, x, uu, rnd_mode);
- mpfr_restore_emin_emax();
- mpfr_check_range(y, rnd_mode);
- }
+ int inexact;
+
+ if (u) /* if u=0, do nothing */
+ {
+ MPFR_INIT1(up, uu, BITS_PER_MP_LIMB, 1);
+ count_leading_zeros(cnt, (mp_limb_t) u);
+ *up = (mp_limb_t) u << cnt;
+ MPFR_EXP(uu) = BITS_PER_MP_LIMB-cnt;
+
+ /* Optimization note: Exponent operations may be removed
+ if mpfr_add works even when uu is out-of-range. */
+ mpfr_save_emin_emax();
+ inexact = mpfr_add(y, x, uu, rnd_mode);
+ mpfr_restore_emin_emax();
+ mpfr_check_range(y, rnd_mode);
+ return inexact;
+ }
else
- mpfr_set (y, x, rnd_mode);
+ return mpfr_set (y, x, rnd_mode);
}