1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Jim Winstead <jimw@php.net> | 14 | Stig Sæther Bakken <ssb@php.net> | 15 +----------------------------------------------------------------------+ 16 */ 17 18 #ifndef PHP_MATH_H 19 #define PHP_MATH_H 20 21 PHPAPI double _php_math_round(double value, int places, int mode); 22 PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep); 23 PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len); 24 PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base); 25 PHPAPI zend_long _php_math_basetolong(zval *arg, int base); 26 PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret); 27 PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base); 28 29 #include <math.h> 30 31 #ifndef M_E 32 #define M_E 2.7182818284590452354 /* e */ 33 #endif 34 35 #ifndef M_LOG2E 36 #define M_LOG2E 1.4426950408889634074 /* log_2 e */ 37 #endif 38 39 #ifndef M_LOG10E 40 #define M_LOG10E 0.43429448190325182765 /* log_10 e */ 41 #endif 42 43 #ifndef M_LN2 44 #define M_LN2 0.69314718055994530942 /* log_e 2 */ 45 #endif 46 47 #ifndef M_LN10 48 #define M_LN10 2.30258509299404568402 /* log_e 10 */ 49 #endif 50 51 #ifndef M_PI 52 #define M_PI 3.14159265358979323846 /* pi */ 53 #endif 54 55 #ifndef M_PI_2 56 #define M_PI_2 1.57079632679489661923 /* pi/2 */ 57 #endif 58 59 #ifndef M_PI_4 60 #define M_PI_4 0.78539816339744830962 /* pi/4 */ 61 #endif 62 63 #ifndef M_1_PI 64 #define M_1_PI 0.31830988618379067154 /* 1/pi */ 65 #endif 66 67 #ifndef M_2_PI 68 #define M_2_PI 0.63661977236758134308 /* 2/pi */ 69 #endif 70 71 #ifndef M_SQRTPI 72 #define M_SQRTPI 1.77245385090551602729 /* sqrt(pi) */ 73 #endif 74 75 #ifndef M_2_SQRTPI 76 #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ 77 #endif 78 79 #ifndef M_LNPI 80 #define M_LNPI 1.14472988584940017414 /* ln(pi) */ 81 #endif 82 83 #ifndef M_EULER 84 #define M_EULER 0.57721566490153286061 /* Euler constant */ 85 #endif 86 87 #ifndef M_SQRT2 88 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ 89 #endif 90 91 #ifndef M_SQRT1_2 92 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ 93 #endif 94 95 #ifndef M_SQRT3 96 #define M_SQRT3 1.73205080756887729352 /* sqrt(3) */ 97 #endif 98 99 /* Define rounding modes (all are round-to-nearest) */ 100 #ifndef PHP_ROUND_HALF_UP 101 #define PHP_ROUND_HALF_UP 0x01 /* Arithmetic rounding, up == away from zero */ 102 #endif 103 104 #ifndef PHP_ROUND_HALF_DOWN 105 #define PHP_ROUND_HALF_DOWN 0x02 /* Down == towards zero */ 106 #endif 107 108 #ifndef PHP_ROUND_HALF_EVEN 109 #define PHP_ROUND_HALF_EVEN 0x03 /* Banker's rounding */ 110 #endif 111 112 #ifndef PHP_ROUND_HALF_ODD 113 #define PHP_ROUND_HALF_ODD 0x04 114 #endif 115 116 #endif /* PHP_MATH_H */ 117