php_math.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Jim Winstead <jimw@php.net> |
  16. | Stig Sæther Bakken <ssb@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef PHP_MATH_H
  20. #define PHP_MATH_H
  21. PHPAPI double _php_math_round(double, int, int);
  22. PHPAPI zend_string *_php_math_number_format(double, int, char, char);
  23. PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t);
  24. PHPAPI zend_string * _php_math_longtobase(zval *arg, int base);
  25. PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
  26. PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret);
  27. PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base);
  28. PHP_FUNCTION(sin);
  29. PHP_FUNCTION(cos);
  30. PHP_FUNCTION(tan);
  31. PHP_FUNCTION(asin);
  32. PHP_FUNCTION(acos);
  33. PHP_FUNCTION(atan);
  34. PHP_FUNCTION(atan2);
  35. PHP_FUNCTION(pi);
  36. PHP_FUNCTION(exp);
  37. PHP_FUNCTION(log);
  38. PHP_FUNCTION(log10);
  39. PHP_FUNCTION(is_finite);
  40. PHP_FUNCTION(is_infinite);
  41. PHP_FUNCTION(is_nan);
  42. PHP_FUNCTION(pow);
  43. PHP_FUNCTION(sqrt);
  44. PHP_FUNCTION(rand);
  45. PHP_FUNCTION(mt_srand);
  46. PHP_FUNCTION(mt_rand);
  47. PHP_FUNCTION(mt_getrandmax);
  48. PHP_FUNCTION(abs);
  49. PHP_FUNCTION(ceil);
  50. PHP_FUNCTION(floor);
  51. PHP_FUNCTION(round);
  52. PHP_FUNCTION(decbin);
  53. PHP_FUNCTION(dechex);
  54. PHP_FUNCTION(decoct);
  55. PHP_FUNCTION(bindec);
  56. PHP_FUNCTION(hexdec);
  57. PHP_FUNCTION(octdec);
  58. PHP_FUNCTION(base_convert);
  59. PHP_FUNCTION(number_format);
  60. PHP_FUNCTION(fmod);
  61. PHP_FUNCTION(deg2rad);
  62. PHP_FUNCTION(rad2deg);
  63. PHP_FUNCTION(intdiv);
  64. /*
  65. WARNING: these functions are expermental: they could change their names or
  66. disappear in the next version of PHP!
  67. */
  68. PHP_FUNCTION(hypot);
  69. PHP_FUNCTION(expm1);
  70. PHP_FUNCTION(log1p);
  71. PHP_FUNCTION(sinh);
  72. PHP_FUNCTION(cosh);
  73. PHP_FUNCTION(tanh);
  74. PHP_FUNCTION(asinh);
  75. PHP_FUNCTION(acosh);
  76. PHP_FUNCTION(atanh);
  77. #include <math.h>
  78. #ifndef M_E
  79. #define M_E 2.7182818284590452354 /* e */
  80. #endif
  81. #ifndef M_LOG2E
  82. #define M_LOG2E 1.4426950408889634074 /* log_2 e */
  83. #endif
  84. #ifndef M_LOG10E
  85. #define M_LOG10E 0.43429448190325182765 /* log_10 e */
  86. #endif
  87. #ifndef M_LN2
  88. #define M_LN2 0.69314718055994530942 /* log_e 2 */
  89. #endif
  90. #ifndef M_LN10
  91. #define M_LN10 2.30258509299404568402 /* log_e 10 */
  92. #endif
  93. #ifndef M_PI
  94. #define M_PI 3.14159265358979323846 /* pi */
  95. #endif
  96. #ifndef M_PI_2
  97. #define M_PI_2 1.57079632679489661923 /* pi/2 */
  98. #endif
  99. #ifndef M_PI_4
  100. #define M_PI_4 0.78539816339744830962 /* pi/4 */
  101. #endif
  102. #ifndef M_1_PI
  103. #define M_1_PI 0.31830988618379067154 /* 1/pi */
  104. #endif
  105. #ifndef M_2_PI
  106. #define M_2_PI 0.63661977236758134308 /* 2/pi */
  107. #endif
  108. #ifndef M_SQRTPI
  109. #define M_SQRTPI 1.77245385090551602729 /* sqrt(pi) */
  110. #endif
  111. #ifndef M_2_SQRTPI
  112. #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
  113. #endif
  114. #ifndef M_LNPI
  115. #define M_LNPI 1.14472988584940017414 /* ln(pi) */
  116. #endif
  117. #ifndef M_EULER
  118. #define M_EULER 0.57721566490153286061 /* Euler constant */
  119. #endif
  120. #ifndef M_SQRT2
  121. #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
  122. #endif
  123. #ifndef M_SQRT1_2
  124. #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
  125. #endif
  126. #ifndef M_SQRT3
  127. #define M_SQRT3 1.73205080756887729352 /* sqrt(3) */
  128. #endif
  129. /* Define rounding modes (all are round-to-nearest) */
  130. #ifndef PHP_ROUND_HALF_UP
  131. #define PHP_ROUND_HALF_UP 0x01 /* Arithmetic rounding, up == away from zero */
  132. #endif
  133. #ifndef PHP_ROUND_HALF_DOWN
  134. #define PHP_ROUND_HALF_DOWN 0x02 /* Down == towards zero */
  135. #endif
  136. #ifndef PHP_ROUND_HALF_EVEN
  137. #define PHP_ROUND_HALF_EVEN 0x03 /* Banker's rounding */
  138. #endif
  139. #ifndef PHP_ROUND_HALF_ODD
  140. #define PHP_ROUND_HALF_ODD 0x04
  141. #endif
  142. #endif /* PHP_MATH_H */