]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/e_scalb.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / math / e_scalb.c
index 146422cd855de3c60a6939995d584401a7dc360f..96c3579aad541b5bd307035931311a253ae6be79 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
 
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -26,10 +25,7 @@ __attribute__ ((noinline))
 invalid_fn (double x, double fn)
 {
   if (__rint (fn) != fn)
-    {
-      feraiseexcept (FE_INVALID);
-      return __nan ("");
-    }
+    return (fn - fn) / (fn - fn);
   else if (fn > 65000.0)
     return __scalbn (x, 65000);
   else
@@ -40,17 +36,17 @@ invalid_fn (double x, double fn)
 double
 __ieee754_scalb (double x, double fn)
 {
-  if (__builtin_expect (__isnan (x), 0))
+  if (__glibc_unlikely (isnan (x)))
     return x * fn;
-  if (__builtin_expect (!__finite (fn), 0))
+  if (__glibc_unlikely (!isfinite (fn)))
     {
-      if (__isnan (fn) || fn > 0.0)
+      if (isnan (fn) || fn > 0.0)
        return x * fn;
       if (x == 0.0)
        return x;
       return x / -fn;
     }
-  if (__builtin_expect ((double) (int) fn != fn, 0))
+  if (__glibc_unlikely (fabs (fn) >= 0x1p31 || (double) (int) fn != fn))
     return invalid_fn (x, fn);
 
   return __scalbn (x, (int) fn);