mirror of
https://github.com/php/php-src.git
synced 2024-12-04 23:34:25 +08:00
Merge branch 'pull-request/658'
This commit is contained in:
commit
37e91cc5d3
@ -338,7 +338,7 @@ fi
|
||||
dnl
|
||||
dnl Check for available functions
|
||||
dnl
|
||||
AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
|
||||
AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p log2 hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
|
||||
AC_FUNC_FNMATCH
|
||||
|
||||
dnl
|
||||
|
@ -661,22 +661,35 @@ PHP_FUNCTION(log1p)
|
||||
PHP_FUNCTION(log)
|
||||
{
|
||||
double num, base = 0;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &num, &base) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() == 1) {
|
||||
RETURN_DOUBLE(log(num));
|
||||
}
|
||||
|
||||
#ifdef HAVE_LOG2
|
||||
if (base == 2.0) {
|
||||
RETURN_DOUBLE(log2(num));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (base == 10.0) {
|
||||
RETURN_DOUBLE(log10(num));
|
||||
}
|
||||
|
||||
if (base == 1.0) {
|
||||
RETURN_DOUBLE(php_get_nan());
|
||||
}
|
||||
|
||||
if (base <= 0.0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "base must be greater than 0");
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "base must be greater than 0");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (base == 1) {
|
||||
RETURN_DOUBLE(php_get_nan());
|
||||
} else {
|
||||
RETURN_DOUBLE(log(num) / log(base));
|
||||
}
|
||||
|
||||
RETURN_DOUBLE(log(num) / log(base));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user