summaryrefslogtreecommitdiff
path: root/tests/test6/test6.c
blob: fc99598831c67e50370bb4740ac65c6404b234ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
}