Subversion Repositories Kolibri OS

Rev

Rev 5640 | Rev 5730 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //IO library
  2. #ifndef INCLUDE_MATH_H
  3. #define INCLUDE_MATH_H
  4. #print "[include <math.h>]\n"
  5.  
  6. #ifndef INCLUDE_KOLIBRI_H
  7. #include "../lib/kolibri.h"
  8. #endif
  9.  
  10. :struct MATH
  11. {
  12.         float pi();
  13.         float cos(float x);
  14.         float sin(float x);
  15.         float sqrt(float x);
  16.         float tan(float x);
  17.         float abs(float x);
  18. }math;
  19. :float MATH::abs(float x)
  20. {
  21.         IF(x<0)return -x;
  22.         return x;
  23. }
  24.        
  25. :float MATH::cos(float x)
  26. {
  27.         float r;
  28.         asm
  29.         {
  30.                 fld x
  31.                 fcos
  32.                 fstp r
  33.         }
  34.         return r;
  35. }
  36. :float MATH::sin(float x)
  37. {
  38.         float r;
  39.         asm
  40.         {
  41.                 fld x
  42.                 fsin
  43.                 fstp r
  44.         }
  45.         return r;
  46. }
  47. :float MATH::sqrt(float x)
  48. {
  49.         float r;
  50.         asm
  51.         {
  52.                 fld x
  53.                 fsqrt
  54.                 fstp r
  55.         }
  56.         return r;
  57. }
  58. :float MATH::tan(float x)
  59. {
  60.         float r;
  61.         asm
  62.         {
  63.                 fld x
  64.                 fld1
  65.                 fpatan
  66.                 fstp r
  67.         }
  68.         return r;
  69. }
  70. #endif