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