summaryrefslogtreecommitdiff
path: root/tests/test6/test6.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test6/test6.c')
-rw-r--r--tests/test6/test6.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test6/test6.c b/tests/test6/test6.c
new file mode 100644
index 0000000..fc99598
--- /dev/null
+++ b/tests/test6/test6.c
@@ -0,0 +1,36 @@
+#include <math.h>
+#include <stdio.h>
+
+//#if 1 //(UGLY_IEEE754_FLOAT32_HACK :-)
+/*
+static inline float todB_a(const float *x){
+ return (float)((*(int *)x)&0x7fffffff) * 7.17711438e-7f -764.6161886f;
+}
+*/
+static inline float todB_a(const float *x){
+ union {
+ //int32_t i;
+ int i;
+ float f;
+ } ix;
+ ix.f = *x;
+ ix.i = ix.i&0x7fffffff;
+ return (float)(ix.i * 7.17711438e-7f -764.6161886f);
+}
+//#else
+
+static inline float todB_a2(const float *x){
+ return (*(x)==0?-400.f:logf(*(x)**(x))*4.34294480f);
+}
+
+//#endif
+
+int main() {
+ float f;
+
+ for(f=1.f;f<100000000.f;f*=1.2f)
+ printf("%f\t%f\n", todB_a(&f), todB_a2(&f));
+
+ return 0;
+}
+