From 96dd59b90fc985162ed290d5788b52a032d65802 Mon Sep 17 00:00:00 2001 From: zimmerma Date: Mon, 6 Feb 2017 12:58:48 +0000 Subject: [tests/tsqr.c] added a corner underflow case git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11258 280ebfd0-de03-0410-8827-d642c229c3f4 --- src/sqr.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/sqr.c') diff --git a/src/sqr.c b/src/sqr.c index 0be9ba19d..36587cec7 100644 --- a/src/sqr.c +++ b/src/sqr.c @@ -65,6 +65,14 @@ mpfr_sqr_1 (mpfr_ptr a, mpfr_srcptr b, mpfr_rnd_t rnd_mode, mpfr_prec_t p) a >= 0.111...111[1]*2^(emin-1), there is no underflow. */ if (MPFR_UNLIKELY(ax < __gmpfr_emin)) { + /* Note: for emin=2*k+1, a >= 0.111...111*2^(emin-1) is not possible, + i.e., a >= (1 - 2^(-p))*2^(2k), since we need a = b^2 with EXP(b)=k, + and the largest such b is (1 - 2^(-p))*2^k satisfies + b^2 < (1 - 2^(-p))*2^(2k). + For emin=2*k, it is only possible for some values of p: it is not + possible for p=53, because the largest significand is 6369051672525772 + but its square has only 52 leading ones. For p=24 it is possible, + with b = 11863283, whose square has 24 leading ones. */ if ((ax == __gmpfr_emin - 1) && (ap[0] == ~mask) && ((rnd_mode == MPFR_RNDN && rb) || (MPFR_IS_LIKE_RNDA(rnd_mode, MPFR_IS_NEG (a)) && (rb | sb)))) -- cgit v1.2.1