diff options
author | lfousse <lfousse@280ebfd0-de03-0410-8827-d642c229c3f4> | 2011-01-13 18:39:57 +0000 |
---|---|---|
committer | lfousse <lfousse@280ebfd0-de03-0410-8827-d642c229c3f4> | 2011-01-13 18:39:57 +0000 |
commit | 04178cba3026e64d0e7332c2458ad4bc6b47293b (patch) | |
tree | 1d22b5987d831fc4ea0947c482631ba1808153e3 /src/atan2.c | |
parent | 12bcc8280a3db1dd5c236ab411cffb97c5570362 (diff) | |
download | mpfr-04178cba3026e64d0e7332c2458ad4bc6b47293b.tar.gz |
[src/atan2.c] "Exact" division can be inexact because of the exponent range.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7338 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/atan2.c')
-rw-r--r-- | src/atan2.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/atan2.c b/src/atan2.c index 444546495..b1ae9eaf6 100644 --- a/src/atan2.c +++ b/src/atan2.c @@ -161,10 +161,17 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) int r; mpfr_t yoverx; mpfr_init2 (yoverx, MPFR_PREC (y)); - mpfr_div_2si (yoverx, y, MPFR_EXP (x) - 1, MPFR_RNDN); - r = mpfr_atan (dest, yoverx, rnd_mode); - mpfr_clear (yoverx); - return r; + if (MPFR_LIKELY (mpfr_div_2si (yoverx, y, MPFR_EXP (x) - 1, MPFR_RNDN) == 0)) + { + r = mpfr_atan (dest, yoverx, rnd_mode); + mpfr_clear (yoverx); + return r; + } + else + { + /* Division is inexact because of a small exponent range */ + mpfr_clear (yoverx); + } } MPFR_SAVE_EXPO_MARK (expo); |