X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=regis;a=blobdiff_plain;f=fixed.h;fp=fixed.h;h=dbc8bbea5586d0c9945bb9f1bce1e2aec8140fe3;hp=0000000000000000000000000000000000000000;hb=4ac276ea513d4460f9db8c43b4dbde5ebad652b5;hpb=46aa499cb189f9eb533e1e5a95a3770a0b3df8b4 diff --git a/fixed.h b/fixed.h new file mode 100644 index 0000000..dbc8bbe --- /dev/null +++ b/fixed.h @@ -0,0 +1,18 @@ +#ifndef FIXED_H_ +#define FIXED_H_ + +#include + +#define ftox16(x) (int32_t)((x) * 65536.0f) +#define itox16(x) (int32_t)((x) << 16) + +#define x16tof(x) (float)((x) / 65536.0f) +#define x16toi(x) ((x) >> 16) + +#define x16mul(a, b) (int32_t)(((int32_t)(a) >> 8) * ((int32_t)(b) >> 8)) +/*int32_t x16div(register int32_t num, register int32_t denom);*/ +#define x16div(a, b) (int32_t)(((int64_t)(a) << 16) / (b)) + +#define x16sq(x) x16mul(x, x) + +#endif /* FIXED_H_ */