]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/e_scalbf.c
Merge branch 'master' of git://sourceware.org/git/glibc
[thirdparty/glibc.git] / math / e_scalbf.c
index 98f85ab04f6fff5cb69f70879a1fc4d9247cdedd..aa08b9a81deeed756a5492bf07dabebd9348211f 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>
 
@@ -25,11 +24,8 @@ static float
 __attribute__ ((noinline))
 invalid_fn (float x, float fn)
 {
-  if (__rintf (fn) != fn)
-    {
-      feraiseexcept (FE_INVALID);
-      return __nan ("");
-    }
+  if (rintf (fn) != fn)
+    return (fn - fn) / (fn - fn);
   else if (fn > 65000.0f)
     return __scalbnf (x, 65000);
   else
@@ -40,17 +36,17 @@ invalid_fn (float x, float fn)
 float
 __ieee754_scalbf (float x, float fn)
 {
-  if (__builtin_expect (__isnanf (x), 0))
+  if (__glibc_unlikely (isnan (x)))
     return x * fn;
-  if (__builtin_expect (!__finitef (fn), 0))
+  if (__glibc_unlikely (!isfinite (fn)))
     {
-      if (__isnanf (fn) || fn > 0.0f)
+      if (isnan (fn) || fn > 0.0f)
        return x * fn;
       if (x == 0.0f)
        return x;
       return x / -fn;
     }
-  if (__builtin_expect ((float) (int) fn != fn, 0))
+  if (__glibc_unlikely (fabsf (fn) >= 0x1p31f || (float) (int) fn != fn))
     return invalid_fn (x, fn);
 
   return __scalbnf (x, (int) fn);