OSDN Git Service

math: fix logb(-0.0) in downward rounding mode
authorSzabolcs Nagy <nsz@port70.net>
Mon, 2 Sep 2013 23:35:46 +0000 (23:35 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Thu, 5 Sep 2013 11:30:07 +0000 (11:30 +0000)
use -1/(x*x) instead of -1/(x+0) to return -inf, -0+0 is -0 in
downward rounding mode

src/math/logb.c
src/math/logbf.c
src/math/logbl.c

index 624425a..7f8bdfa 100644 (file)
@@ -1,4 +1,4 @@
-#include "libm.h"
+#include <math.h>
 
 /*
 special cases:
@@ -12,6 +12,6 @@ double logb(double x)
        if (!isfinite(x))
                return x * x;
        if (x == 0)
-               return -1/(x+0);
+               return -1/(x*x);
        return ilogb(x);
 }
index 950d356..a0a0b5e 100644 (file)
@@ -1,10 +1,10 @@
-#include "libm.h"
+#include <math.h>
 
 float logbf(float x)
 {
        if (!isfinite(x))
                return x * x;
        if (x == 0)
-               return -1/(x+0);
+               return -1/(x*x);
        return ilogbf(x);
 }
index f385074..962973a 100644 (file)
@@ -1,4 +1,4 @@
-#include "libm.h"
+#include <math.h>
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double logbl(long double x)
 {
@@ -10,7 +10,7 @@ long double logbl(long double x)
        if (!isfinite(x))
                return x * x;
        if (x == 0)
-               return -1/(x+0);
+               return -1/(x*x);
        return ilogbl(x);
 }
 #endif