summaryrefslogtreecommitdiff
path: root/get_ld.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-09 14:06:37 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-09 14:06:37 +0000
commitc12a815ae10dc7ac2c13d5d9bcca9ca0d1f3b3bc (patch)
tree37fc20727ee7b0db9e13491ab7b6597907400783 /get_ld.c
parentbb69a471064759b05e8d00a1a5ac3ffdc87d3355 (diff)
downloadmpfr-c12a815ae10dc7ac2c13d5d9bcca9ca0d1f3b3bc.tar.gz
fixed possible overflow when EXP=1024
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2155 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'get_ld.c')
-rw-r--r--get_ld.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/get_ld.c b/get_ld.c
index 9ca8b81ab..749043572 100644
--- a/get_ld.c
+++ b/get_ld.c
@@ -20,6 +20,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
+#include <stdio.h>
#include <float.h>
#include "gmp.h"
@@ -64,10 +65,10 @@ mpfr_get_ld (mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_set (y, x, rnd_mode);
negative = MPFR_SIGN(y) < 0;
e = MPFR_EXP(y);
- if (e > 1024)
+ if (e > 1023)
{
- sh = e - 1024;
- MPFR_EXP(y) = 1024;
+ sh = e - 1023;
+ MPFR_EXP(y) = 1023;
}
else if (e < -1021)
{
@@ -78,7 +79,7 @@ mpfr_get_ld (mpfr_srcptr x, mp_rnd_t rnd_mode)
{
sh = 0;
}
- /* now -1021 <= e - sh = EXP(y) <= 1024 */
+ /* now -1021 <= e - sh = EXP(y) <= 1023 */
r = 0.0;
mpfr_init2 (z, DBL_MANT_DIG);