projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
asm for log2
[oweals/musl.git]
/
src
/
math
/
logb.c
1
#include <limits.h>
2
#include "libm.h"
3
4
/*
5
special cases:
6
logb(+-0) = -inf
7
logb(+-inf) = +inf
8
logb(nan) = nan
9
these are calculated at runtime to raise fp exceptions
10
*/
11
12
double logb(double x) {
13
int i = ilogb(x);
14
15
if (i == FP_ILOGB0)
16
return -1.0/fabs(x);
17
if (i == FP_ILOGBNAN || i == INT_MAX)
18
return x * x;
19
return i;
20
}