diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-24 14:51:42 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-24 14:51:42 +0000 |
commit | 8dd0bbfd0dc2fee95d214c962d013d97de22d084 (patch) | |
tree | f67b951ca2647bc16e196631afc487912630b999 /tests/tmul_2exp.c | |
parent | 651c49824306f6fd3a0c1336882160ea678f4df7 (diff) | |
download | mpfr-8dd0bbfd0dc2fee95d214c962d013d97de22d084.tar.gz |
Avoid integer overflow.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2808 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tmul_2exp.c')
-rw-r--r-- | tests/tmul_2exp.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/tmul_2exp.c b/tests/tmul_2exp.c index 645210f72..f2e85e1c8 100644 --- a/tests/tmul_2exp.c +++ b/tests/tmul_2exp.c @@ -118,10 +118,12 @@ main (int argc, char *argv[]) if (MPFR_EXP_MAX >= LONG_MAX/2 && MPFR_EXP_MIN <= LONG_MAX/2-LONG_MAX-1) { + unsigned long lmp1 = (unsigned long) LONG_MAX + 1; + mpfr_set_ui (w, 1, GMP_RNDN); mpfr_mul_2ui (w, w, LONG_MAX/2, GMP_RNDZ); - mpfr_div_2ui (w, w, LONG_MAX+1, GMP_RNDZ); - mpfr_mul_2ui (w, w, LONG_MAX+1-LONG_MAX/2, GMP_RNDZ); + mpfr_div_2ui (w, w, lmp1, GMP_RNDZ); + mpfr_mul_2ui (w, w, lmp1 - LONG_MAX/2, GMP_RNDZ); if (!mpfr_cmp_ui (w, 1)) { printf ("Underflow LONG_MAX error!\n"); |