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