projects
/
oweals
/
musl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add sched_getcpu vDSO support
[oweals/musl.git]
/
src
/
math
/
logb.c
diff --git
a/src/math/logb.c
b/src/math/logb.c
index f7cd7613069bc172c345bada309a3151a016cfab..7f8bdfae19f8ca0a85b611d38a73695ccf588e43 100644
(file)
--- a/
src/math/logb.c
+++ b/
src/math/logb.c
@@
-1,20
+1,17
@@
-#include <limits.h>
-#include "libm.h"
+#include <math.h>
/*
special cases:
/*
special cases:
- logb(+-0) = -inf
+ logb(+-0) = -inf
, and raise divbyzero
logb(+-inf) = +inf
logb(nan) = nan
logb(+-inf) = +inf
logb(nan) = nan
-these are calculated at runtime to raise fp exceptions
*/
*/
-double logb(double x) {
- int i = ilogb(x);
-
- if (i == FP_ILOGB0)
- return -1.0/fabs(x);
- if (i == FP_ILOGBNAN || i == INT_MAX)
+double logb(double x)
+{
+ if (!isfinite(x))
return x * x;
return x * x;
- return i;
+ if (x == 0)
+ return -1/(x*x);
+ return ilogb(x);
}
}