Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //IO library
  2. #ifndef INCLUDE_MATH_C
  3. #define INCLUDE_MATH_C
  4.  
  5. static inline signed math_round(float x)
  6. {
  7.         x+=0.6;
  8.         return x;
  9. }
  10. static inline signed math_ceil(float x)
  11. {
  12.         long z = (long)x;
  13.         if(z<x) return ++z;
  14.         return z;
  15. }
  16. static inline float math_floor(float x)
  17. {
  18.         signed long z = x;
  19.         if(z==x)return x;
  20.         if(z<0) return --z;
  21.         return z;
  22. }
  23. static inline float math_abs(float x)
  24. {
  25.         if(x<0)return -x;
  26.         return x;
  27. }
  28.  
  29. /*
  30. static inline float math_cos(float x)
  31. {
  32.         float r;
  33.         asm
  34.         {
  35.                 fld x
  36.                 fcos
  37.                 fstp r
  38.         }
  39.         return r;
  40. }
  41. static inline float math_sin(float x)
  42. {
  43.         float r;
  44.         asm
  45.         {
  46.                 fld x
  47.                 fsin
  48.                 fstp r
  49.         }
  50.         return r;
  51. }
  52. static inline float math_sqrt(float x)
  53. {
  54.         float r;
  55.         asm
  56.         {
  57.                 fld x
  58.                 fsqrt
  59.                 fstp r
  60.         }
  61.         return r;
  62. }
  63. static inline float math_tan(float x)
  64. {
  65.         float r;
  66.         asm
  67.         {
  68.                 fld x
  69.                 fld1
  70.                 fpatan
  71.                 fstp r
  72.         }
  73.         return r;
  74. }
  75. */
  76. #endif