summaryrefslogtreecommitdiff
path: root/src/math/logbf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/logbf.c')
-rw-r--r--src/math/logbf.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/math/logbf.c b/src/math/logbf.c
new file mode 100644
index 00000000..934827f8
--- /dev/null
+++ b/src/math/logbf.c
@@ -0,0 +1,12 @@
+#include <limits.h>
+#include "libm.h"
+
+float logbf(float x) {
+ int i = ilogbf(x);
+
+ if (i == FP_ILOGB0)
+ return -1.0f/fabsf(x);
+ if (i == FP_ILOGBNAN || i == INT_MAX)
+ return x * x;
+ return i;
+}