summaryrefslogtreecommitdiff
path: root/src/sqrt.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-17 12:53:46 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-17 12:53:46 +0000
commit2bb722757f45d508ee2cf227ef8c6a93d4392b0f (patch)
treed90218ba2a14f125f5c00df626ef6a385725a81f /src/sqrt.c
parent915f9eda1e824bb5c4c96feff7472888e960a0c9 (diff)
downloadmpfr-2bb722757f45d508ee2cf227ef8c6a93d4392b0f.tar.gz
[tests/tsqrt.c] improved coverage
[src/sqrt.c] added comments git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12292 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sqrt.c')
-rw-r--r--src/sqrt.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sqrt.c b/src/sqrt.c
index 0477c389d..6d2f50740 100644
--- a/src/sqrt.c
+++ b/src/sqrt.c
@@ -152,8 +152,13 @@ mpfr_sqrt1 (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
{
if (rnd_mode == MPFR_RNDN)
{
+ /* The smallest positive number is 0.5^2^emin, and its predecessor
+ with unbounded exponent range is (1-2^(-p))*2^(emin-1), thus if
+ the result is >= the rounding boundary (1-2^(-p-1))*2^(emin-1),
+ there is no underflow. */
if ((exp_r == __gmpfr_emin - 1) && (rp[0] == ~mask) && rb)
goto rounding; /* no underflow */
+ /* If the result is <= 0.5^2^(emin-1), we should round to 0. */
if (exp_r < __gmpfr_emin - 1 || (rp[0] == MPFR_LIMB_HIGHBIT && sb == 0))
rnd_mode = MPFR_RNDZ;
}