fixed.h 503 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _FIXED_H
  2. #define _FIXED_H
  3. // Bit length of the decimal part, change it to change the precision :
  4. #define DB 12
  5. #define MOD(x, y) ((x)<0 ? (y)+(x)%(y) : (x)%(y))
  6. typedef int fix;
  7. // Fixed point manipulations functions and macros :
  8. char* fixtostr (fix n, char* string);
  9. fix ftofix(float f);
  10. float fixtof(fix f);
  11. #define FIX(x) ((x)<<DB)
  12. #define UNFIX(x) ((x)>>DB)
  13. fix fdiv(fix x, fix y);
  14. fix fmul(fix x, fix y);
  15. fix fsin(fix a);
  16. fix fcos(fix a);
  17. fix ftan(fix a);
  18. #endif // _FIXED_H