1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 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 20 #ifndef PHP_MATH_H 21 #define PHP_MATH_H 22 23 PHPAPI double _php_math_round(double, int, int); 24 PHPAPI zend_string *_php_math_number_format(double, int, char, char); 25 PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t); 26 PHPAPI zend_string * _php_math_longtobase(zval *arg, int base); 27 PHPAPI zend_long _php_math_basetolong(zval *arg, int base); 28 PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret); 29 PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base); 30 31 PHP_FUNCTION(sin); 32 PHP_FUNCTION(cos); 33 PHP_FUNCTION(tan); 34 PHP_FUNCTION(asin); 35 PHP_FUNCTION(acos); 36 PHP_FUNCTION(atan); 37 PHP_FUNCTION(atan2); 38 PHP_FUNCTION(pi); 39 PHP_FUNCTION(exp); 40 PHP_FUNCTION(log); 41 PHP_FUNCTION(log10); 42 PHP_FUNCTION(is_finite); 43 PHP_FUNCTION(is_infinite); 44 PHP_FUNCTION(is_nan); 45 PHP_FUNCTION(pow); 46 PHP_FUNCTION(sqrt); 47 PHP_FUNCTION(rand); 48 PHP_FUNCTION(mt_srand); 49 PHP_FUNCTION(mt_rand); 50 PHP_FUNCTION(mt_getrandmax); 51 PHP_FUNCTION(abs); 52 PHP_FUNCTION(ceil); 53 PHP_FUNCTION(floor); 54 PHP_FUNCTION(round); 55 PHP_FUNCTION(decbin); 56 PHP_FUNCTION(dechex); 57 PHP_FUNCTION(decoct); 58 PHP_FUNCTION(bindec); 59 PHP_FUNCTION(hexdec); 60 PHP_FUNCTION(octdec); 61 PHP_FUNCTION(base_convert); 62 PHP_FUNCTION(number_format); 63 PHP_FUNCTION(fmod); 64 PHP_FUNCTION(deg2rad); 65 PHP_FUNCTION(rad2deg); 66 PHP_FUNCTION(intdiv); 67 68 /* 69 WARNING: these functions are expermental: they could change their names or 70 disappear in the next version of PHP! 71 */ 72 PHP_FUNCTION(hypot); 73 PHP_FUNCTION(expm1); 74 PHP_FUNCTION(log1p); 75 76 PHP_FUNCTION(sinh); 77 PHP_FUNCTION(cosh); 78 PHP_FUNCTION(tanh); 79 80 PHP_FUNCTION(asinh); 81 PHP_FUNCTION(acosh); 82 PHP_FUNCTION(atanh); 83 84 #include <math.h> 85 86 #ifndef M_E 87 #define M_E 2.7182818284590452354 /* e */ 88 #endif 89 90 #ifndef M_LOG2E 91 #define M_LOG2E 1.4426950408889634074 /* log_2 e */ 92 #endif 93 94 #ifndef M_LOG10E 95 #define M_LOG10E 0.43429448190325182765 /* log_10 e */ 96 #endif 97 98 #ifndef M_LN2 99 #define M_LN2 0.69314718055994530942 /* log_e 2 */ 100 #endif 101 102 #ifndef M_LN10 103 #define M_LN10 2.30258509299404568402 /* log_e 10 */ 104 #endif 105 106 #ifndef M_PI 107 #define M_PI 3.14159265358979323846 /* pi */ 108 #endif 109 110 #ifndef M_PI_2 111 #define M_PI_2 1.57079632679489661923 /* pi/2 */ 112 #endif 113 114 #ifndef M_PI_4 115 #define M_PI_4 0.78539816339744830962 /* pi/4 */ 116 #endif 117 118 #ifndef M_1_PI 119 #define M_1_PI 0.31830988618379067154 /* 1/pi */ 120 #endif 121 122 #ifndef M_2_PI 123 #define M_2_PI 0.63661977236758134308 /* 2/pi */ 124 #endif 125 126 #ifndef M_SQRTPI 127 #define M_SQRTPI 1.77245385090551602729 /* sqrt(pi) */ 128 #endif 129 130 #ifndef M_2_SQRTPI 131 #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ 132 #endif 133 134 #ifndef M_LNPI 135 #define M_LNPI 1.14472988584940017414 /* ln(pi) */ 136 #endif 137 138 #ifndef M_EULER 139 #define M_EULER 0.57721566490153286061 /* Euler constant */ 140 #endif 141 142 #ifndef M_SQRT2 143 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ 144 #endif 145 146 #ifndef M_SQRT1_2 147 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ 148 #endif 149 150 #ifndef M_SQRT3 151 #define M_SQRT3 1.73205080756887729352 /* sqrt(3) */ 152 #endif 153 154 /* Define rounding modes (all are round-to-nearest) */ 155 #ifndef PHP_ROUND_HALF_UP 156 #define PHP_ROUND_HALF_UP 0x01 /* Arithmetic rounding, up == away from zero */ 157 #endif 158 159 #ifndef PHP_ROUND_HALF_DOWN 160 #define PHP_ROUND_HALF_DOWN 0x02 /* Down == towards zero */ 161 #endif 162 163 #ifndef PHP_ROUND_HALF_EVEN 164 #define PHP_ROUND_HALF_EVEN 0x03 /* Banker's rounding */ 165 #endif 166 167 #ifndef PHP_ROUND_HALF_ODD 168 #define PHP_ROUND_HALF_ODD 0x04 169 #endif 170 171 #endif /* PHP_MATH_H */ 172