Author: dim
Date: Sun Aug  9 10:00:13 2015
New Revision: 286515
URL: https://svnweb.freebsd.org/changeset/base/286515

Log:
  In libm's exp2(3), avoid left-shifting a negative integer, which is
  undefined.  Replace it with the intended value, in a defined way.
  
  Reviewed by:  bde
  MFC after:    3 days

Modified:
  head/lib/msun/src/s_exp2.c

Modified: head/lib/msun/src/s_exp2.c
==============================================================================
--- head/lib/msun/src/s_exp2.c  Sun Aug  9 09:54:29 2015        (r286514)
+++ head/lib/msun/src/s_exp2.c  Sun Aug  9 10:00:13 2015        (r286515)
@@ -376,14 +376,14 @@ exp2(double x)
        /* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
        t = tbl[i0];            /* exp2t[i0] */
        z -= tbl[i0 + 1];       /* eps[i0]   */
-       if (k >= -1021 << 20)
+       if (k >= -(1021 << 20))
                INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
        else
                INSERT_WORDS(twopkp1000, 0x3ff00000 + k + (1000 << 20), 0);
        r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
 
        /* Scale by 2**(k>>20). */
-       if(k >= -1021 << 20) {
+       if(k >= -(1021 << 20)) {
                if (k == 1024 << 20)
                        return (r * 2.0 * 0x1p1023);
                return (r * twopk);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to