foo
[regis] / fixed.h
1 #ifndef FIXED_H_
2 #define FIXED_H_
3
4 #include <stdint.h>
5
6 #define ftox16(x)               (int32_t)((x) * 65536.0f)
7 #define itox16(x)               (int32_t)((x) << 16)
8
9 #define x16tof(x)               (float)((x) / 65536.0f)
10 #define x16toi(x)               ((x) >> 16)
11
12 #define x16mul(a, b)    (int32_t)(((int32_t)(a) >> 8) * ((int32_t)(b) >> 8))
13 /*int32_t x16div(register int32_t num, register int32_t denom);*/
14 #define x16div(a, b)    (int32_t)(((int64_t)(a) << 16) / (b))
15
16 #define x16sq(x)                x16mul(x, x)
17
18 #endif  /* FIXED_H_ */