add significand[fl] math functions
authorRich Felker <dalias@aerifal.cx>
Mon, 13 Aug 2012 18:51:43 +0000 (14:51 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 13 Aug 2012 18:51:43 +0000 (14:51 -0400)
include/math.h
src/math/significand.c [new file with mode: 0644]
src/math/significandf.c [new file with mode: 0644]
src/math/significandl.c [new file with mode: 0644]

index 583dc3dad92aabffb276db57fbb9f3ed2654fbe6..656f7868d8c1e35fd0bc540dceeb18899c127398 100644 (file)
@@ -400,6 +400,10 @@ long double exp10l(long double);
 double      pow10(double);
 float       pow10f(float);
 long double pow10l(long double);
+
+double      significand(double);
+float       significandf(float);
+long double significandl(long double);
 #endif
 
 #ifdef __cplusplus
diff --git a/src/math/significand.c b/src/math/significand.c
new file mode 100644 (file)
index 0000000..40d9aa9
--- /dev/null
@@ -0,0 +1,7 @@
+#define _GNU_SOURCE
+#include <math.h>
+
+double significand(double x)
+{
+       return scalbn(x, -ilogb(x));
+}
diff --git a/src/math/significandf.c b/src/math/significandf.c
new file mode 100644 (file)
index 0000000..8a697e1
--- /dev/null
@@ -0,0 +1,7 @@
+#define _GNU_SOURCE
+#include <math.h>
+
+float significandf(float x)
+{
+       return scalbnf(x, -ilogbf(x));
+}
diff --git a/src/math/significandl.c b/src/math/significandl.c
new file mode 100644 (file)
index 0000000..c1d68cd
--- /dev/null
@@ -0,0 +1,7 @@
+#define _GNU_SOURCE
+#include <math.h>
+
+long double significandl(long double x)
+{
+       return scalbnl(x, -ilogbl(x));
+}