Index: math.c
===================================================================
RCS file: /repository/php4/ext/standard/math.c,v
retrieving revision 1.41
diff -u -r1.41 math.c
--- math.c 6 Jun 2001 13:05:51 -0000 1.41
+++ math.c 31 Jul 2001 23:24:52 -0000
@@ -152,8 +152,6 @@
}
}
/* }}} */
-
-
/* {{{ proto double sin(double number)
Returns the sine of the number in radians */
@@ -265,6 +263,107 @@
}
/* }}} */
+/* {{{ proto double sinh(double number)
+ Returns the hyperbolic sine of the number,
+ defined as (exp(number) - exp(-number))/2 */
+
+PHP_FUNCTION(sinh)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = sinh((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double cosh(double number)
+ Returns the hyperbolic cosine of the number,
+ defined as (exp(number) + exp(-number))/2 */
+
+PHP_FUNCTION(cosh)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = cosh((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+/* }}} */
+/* {{{ proto double tanh(double number)
+ Returns the hyperbolic tangent of the number,
+ defined as sinh(number)/cosh(number) */
+PHP_FUNCTION(tanh)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = tanh((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double asinh(double number)
+ Returns the inverse hyperbolic sine of the number,
+ i.e. the value whose hyperbolic sine is number */
+
+PHP_FUNCTION(asinh)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = asinh((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double acosh(double number)
+ Returns the inverse hyperbolic cosine of the number,
+ i.e. the value whose hyperbolic cosine is number */
+
+PHP_FUNCTION(acosh)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = acosh((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double atanh(double number)
+ Returns the inverse hyperbolic tangent of the number,
+ i.e. the value whose hyperbolic tangent is number */
+
+PHP_FUNCTION(atanh)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = atanh((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+
/* {{{ proto double pi(void)
Returns an approximation of pi */
@@ -307,6 +406,76 @@
}
/* }}} */
+/* {{{ proto double exp2(double number)
+ Returns 2 raised to the power of the number */
+
+PHP_FUNCTION(exp2)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ // libc function is broken in RH Linux 6.1, glibc 2.1.3
+ //return_value->value.dval = exp2((*num)->value.dval);
+ return_value->value.dval = pow(2.0,(*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double exp10(double number)
+ Returns 10 raised to the power of the number */
+
+PHP_FUNCTION(exp10)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ // libc function is broken in RH Linux 6.1, glibc 2.1.3
+ //return_value->value.dval = exp10((*num)->value.dval);
+ return_value->value.dval = pow(10.0,(*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double expm1(double number)
+ Returns exp(number) - 1, computed in a way that accurate even when
+ the value of number is close to zero */
+
+PHP_FUNCTION(expm1)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = expm1((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double log1p(double number)
+ Returns log(1 + number), computed in a way that accurate even when
+ the value of number is close to zero */
+
+PHP_FUNCTION(log1p)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = log1p((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
/* {{{ proto double log(double number)
Returns the natural logarithm of the number */
@@ -323,6 +492,24 @@
}
/* }}} */
+/* {{{ proto double log2(double number)
+ Returns the base-2 logarithm of the number */
+
+PHP_FUNCTION(log2)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ // libc function is broken in RH Linux 6.1, glibc 2.1.3
+ //return_value->value.dval = log2((*num)->value.dval);
+ return_value->value.dval = log((*num)->value.dval)/log(2.0);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
/* {{{ proto double log10(double number)
Returns the base-10 logarithm of the number */
@@ -355,6 +542,40 @@
}
/* }}} */
+/* {{{ proto double cbrt(double number)
+ Returns the cubic root of the number */
+
+PHP_FUNCTION(cbrt)
+{
+ zval **num;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num);
+ return_value->value.dval = cbrt((*num)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+/* {{{ proto double hypot(double num1, double num2)
+ Returns sqrt( num1*num1 + num2*num2) */
+
+PHP_FUNCTION(hypot)
+{
+ zval **num1, **num2;
+
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &num1, &num2) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(num1);
+ convert_to_double_ex(num2);
+ return_value->value.dval = hypot((*num1)->value.dval, (*num2)->value.dval);
+ return_value->type = IS_DOUBLE;
+}
+
+/* }}} */
+
/* {{{ proto double deg2rad(double number)
Converts the number in degrees to the radian equivalent */

