blitz_cclib.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "blitz.h"
  2. #include <math.h>
  3. int bbIntAbs( int x ){
  4. return x>=0 ? x : -x;
  5. }
  6. int bbIntSgn( int x ){
  7. return x==0 ? 0 : (x>0 ? 1 : -1);
  8. }
  9. int bbIntMod( int x,int y ){
  10. return x % y;
  11. }
  12. int bbIntMin( int x,int y ){
  13. return x<y ? x : y;
  14. }
  15. int bbIntMax( int x,int y ){
  16. return x>y ? x : y;
  17. }
  18. void bbIntToLong( BBInt64 *r,int x ){
  19. *r=x;
  20. }
  21. double bbFloatAbs( double x ){
  22. return fabs( x );
  23. }
  24. double bbFloatSgn( double x ){
  25. return x==0 ? 0 : (x>0 ? 1 : -1);
  26. }
  27. double bbFloatPow( double x,double y ){
  28. return pow(x,y);
  29. }
  30. double bbFloatMod( double x,double y ){
  31. return fmod( x,y );
  32. }
  33. double bbFloatMin( double x,double y ){
  34. return x<y ? x : y;
  35. }
  36. double bbFloatMax( double x,double y ){
  37. return x>y ? x : y;
  38. }
  39. void bbFloatToLong( BBInt64 *r,double x ){
  40. *r=x;
  41. }
  42. void bbLongNeg( BBInt64 *r,BBInt64 x ){
  43. *r=-x;
  44. }
  45. void bbLongNot( BBInt64 *r,BBInt64 x ){
  46. *r=~x;
  47. }
  48. void bbLongAbs( BBInt64 *r,BBInt64 x ){
  49. *r=x>=0 ? x : -x;
  50. }
  51. void bbLongSgn( BBInt64 *r,BBInt64 x ){
  52. *r=x>0 ? 1 : (x<0 ? -1 : 0);
  53. }
  54. void bbLongAdd( BBInt64 *r,BBInt64 x,BBInt64 y ){
  55. *r=x+y;
  56. }
  57. void bbLongSub( BBInt64 *r,BBInt64 x,BBInt64 y ){
  58. *r=x-y;
  59. }
  60. void bbLongMul( BBInt64 *r,BBInt64 x,BBInt64 y ){
  61. *r=x*y;
  62. }
  63. void bbLongDiv( BBInt64 *r,BBInt64 x,BBInt64 y ){
  64. *r=x/y;
  65. }
  66. void bbLongMod( BBInt64 *r,BBInt64 x,BBInt64 y ){
  67. *r=x%y;
  68. }
  69. void bbLongMin( BBInt64 *r,BBInt64 x,BBInt64 y ){
  70. *r=x<y ? x : y;
  71. }
  72. void bbLongMax( BBInt64 *r,BBInt64 x,BBInt64 y ){
  73. *r=x>y ? x : y;
  74. }
  75. void bbLongAnd( BBInt64 *r,BBInt64 x,BBInt64 y ){
  76. *r=x&y;
  77. }
  78. void bbLongOrl( BBInt64 *r,BBInt64 x,BBInt64 y ){
  79. *r=x|y;
  80. }
  81. void bbLongXor( BBInt64 *r,BBInt64 x,BBInt64 y ){
  82. *r=x^y;
  83. }
  84. void bbLongShl( BBInt64 *r,BBInt64 x,BBInt64 y ){
  85. *r=x<<y;
  86. }
  87. void bbLongShr( BBInt64 *r,BBInt64 x,BBInt64 y ){
  88. *r=(BBUInt64)x>>(BBUInt64)y;
  89. }
  90. void bbLongSar( BBInt64 *r,BBInt64 x,BBInt64 y ){
  91. *r=x>>y;
  92. }
  93. int bbLongSlt( BBInt64 x,BBInt64 y ){
  94. return x<y;
  95. }
  96. int bbLongSgt( BBInt64 x,BBInt64 y ){
  97. return x>y;
  98. }
  99. int bbLongSle( BBInt64 x,BBInt64 y ){
  100. return x<=y;
  101. }
  102. int bbLongSge( BBInt64 x,BBInt64 y ){
  103. return x>=y;
  104. }
  105. int bbLongSeq( BBInt64 x,BBInt64 y ){
  106. return x==y;
  107. }
  108. int bbLongSne( BBInt64 x,BBInt64 y ){
  109. return x!=y;
  110. }
  111. double bbLongToFloat( BBInt64 x ){
  112. return (double)x;
  113. }