diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-01-07 10:31:43 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-01-07 10:31:43 +0000 |
commit | 01a12126c4e8311d92d6e45b44f0d1d8f3bf88cf (patch) | |
tree | 1fe48656e0d2d9107eab35721e558792ae706f4a /exp2.c | |
parent | f8c34073b2b8849fbdf898b7e7461ed0bf4cff08 (diff) | |
download | mpfr-01a12126c4e8311d92d6e45b44f0d1d8f3bf88cf.tar.gz |
fixed pb for underflow and rounding to nearest
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2141 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'exp2.c')
-rw-r--r-- | exp2.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -65,9 +65,16 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /* since the smallest representable non-zero float is 1/2*2^__gmpfr_emin, if x < __gmpfr_emin - 1, the result is either 1/2*2^__gmpfr_emin or 0 */ - MPFR_ASSERTN(MPFR_EMIN_MIN - 1 >= LONG_MIN); + MPFR_ASSERTN(MPFR_EMIN_MIN - 2 >= LONG_MIN); if (mpfr_cmp_si_2exp (x, __gmpfr_emin - 1, 0) < 0) - return mpfr_set_underflow (y, rnd_mode, 1); + { + mp_rnd_t rnd2 = rnd_mode; + /* in round to nearest mode, round to zero when x <= __gmpfr_emin-2 */ + if (rnd_mode == GMP_RNDN && + mpfr_cmp_si_2exp (x, __gmpfr_emin - 2, 0) <= 0) + rnd2 = GMP_RNDZ; + return mpfr_set_underflow (y, rnd2, 1); + } if (mpfr_isinteger (x)) /* we know that x >= 2^(emin-1) */ { |