#401 : PHPCS (Calculation\Functions)
This commit is contained in:
parent
69e168271a
commit
12590bbf1e
|
@ -807,7 +807,7 @@ class Calculation
|
||||||
),
|
),
|
||||||
'ERROR.TYPE' => array(
|
'ERROR.TYPE' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::ERROR_TYPE',
|
'functionCall' => 'Calculation\Categories::errorType',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'EVEN' => array(
|
'EVEN' => array(
|
||||||
|
@ -1129,7 +1129,7 @@ class Calculation
|
||||||
),
|
),
|
||||||
'ISBLANK' => array(
|
'ISBLANK' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_BLANK',
|
'functionCall' => 'Calculation\Categories::isBlank',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISERR' => array(
|
'ISERR' => array(
|
||||||
|
@ -1144,32 +1144,32 @@ class Calculation
|
||||||
),
|
),
|
||||||
'ISEVEN' => array(
|
'ISEVEN' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_EVEN',
|
'functionCall' => 'Calculation\Categories::isEven',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISLOGICAL' => array(
|
'ISLOGICAL' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_LOGICAL',
|
'functionCall' => 'Calculation\Categories::isLogical',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISNA' => array(
|
'ISNA' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_NA',
|
'functionCall' => 'Calculation\Categories::isNa',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISNONTEXT' => array(
|
'ISNONTEXT' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_NONTEXT',
|
'functionCall' => 'Calculation\Categories::isNonText',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISNUMBER' => array(
|
'ISNUMBER' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_NUMBER',
|
'functionCall' => 'Calculation\Categories::isNumber',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISODD' => array(
|
'ISODD' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_ODD',
|
'functionCall' => 'Calculation\Categories::isOdd',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'ISPMT' => array(
|
'ISPMT' => array(
|
||||||
|
@ -1184,7 +1184,7 @@ class Calculation
|
||||||
),
|
),
|
||||||
'ISTEXT' => array(
|
'ISTEXT' => array(
|
||||||
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
'category' => Calculation\Categories::CATEGORY_INFORMATION,
|
||||||
'functionCall' => 'Calculation\Categories::IS_TEXT',
|
'functionCall' => 'Calculation\Categories::isText',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
),
|
),
|
||||||
'JIS' => array(
|
'JIS' => array(
|
||||||
|
@ -2526,7 +2526,7 @@ class Calculation
|
||||||
return '"'.$value.'"';
|
return '"'.$value.'"';
|
||||||
// Convert numeric errors to NaN error
|
// Convert numeric errors to NaN error
|
||||||
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
|
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
|
||||||
return Calculation\Functions::NaN();
|
return Calculation\Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -2545,9 +2545,9 @@ class Calculation
|
||||||
if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) {
|
if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) {
|
||||||
return substr($value, 1, -1);
|
return substr($value, 1, -1);
|
||||||
}
|
}
|
||||||
// Convert numeric errors to NaN error
|
// Convert numeric errors to NAN error
|
||||||
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
|
} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
|
||||||
return Calculation\Functions::NaN();
|
return Calculation\Functions::NAN();
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -2645,7 +2645,7 @@ class Calculation
|
||||||
if ($result === null) {
|
if ($result === null) {
|
||||||
return 0;
|
return 0;
|
||||||
} elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
|
} elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
|
||||||
return Calculation\Functions::NaN();
|
return Calculation\Functions::NAN();
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,7 @@ class Database
|
||||||
// Return
|
// Return
|
||||||
$colData = self::getFilteredColumn($database, $field, $criteria);
|
$colData = self::getFilteredColumn($database, $field, $criteria);
|
||||||
if (count($colData) > 1) {
|
if (count($colData) > 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $colData[0];
|
return $colData[0];
|
||||||
|
|
|
@ -309,10 +309,10 @@ class DateTime
|
||||||
$baseYear = \PHPExcel\Shared\Date::getExcelCalendar();
|
$baseYear = \PHPExcel\Shared\Date::getExcelCalendar();
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($year < ($baseYear-1900)) {
|
if ($year < ($baseYear-1900)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) {
|
if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($year < $baseYear) && ($year >= ($baseYear-1900))) {
|
if (($year < $baseYear) && ($year >= ($baseYear-1900))) {
|
||||||
|
@ -332,7 +332,7 @@ class DateTime
|
||||||
|
|
||||||
// Re-validate the year parameter after adjustments
|
// Re-validate the year parameter after adjustments
|
||||||
if (($year < $baseYear) || ($year >= 10000)) {
|
if (($year < $baseYear) || ($year >= 10000)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -422,7 +422,7 @@ class DateTime
|
||||||
if ($hour > 23) {
|
if ($hour > 23) {
|
||||||
$hour = $hour % 24;
|
$hour = $hour % 24;
|
||||||
} elseif ($hour < 0) {
|
} elseif ($hour < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -662,7 +662,7 @@ class DateTime
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($startDate >= $endDate) {
|
if ($startDate >= $endDate) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -678,7 +678,7 @@ class DateTime
|
||||||
$endMonths = $PHPEndDateObject->format('n');
|
$endMonths = $PHPEndDateObject->format('n');
|
||||||
$endYears = $PHPEndDateObject->format('Y');
|
$endYears = $PHPEndDateObject->format('Y');
|
||||||
|
|
||||||
$retVal = Functions::NaN();
|
$retVal = Functions::NAN();
|
||||||
switch ($unit) {
|
switch ($unit) {
|
||||||
case 'D':
|
case 'D':
|
||||||
$retVal = intval($difference);
|
$retVal = intval($difference);
|
||||||
|
@ -735,7 +735,7 @@ class DateTime
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$retVal = Functions::NaN();
|
$retVal = Functions::NAN();
|
||||||
}
|
}
|
||||||
return $retVal;
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1125,7 @@ class DateTime
|
||||||
} elseif ($dateValue == 0.0) {
|
} elseif ($dateValue == 0.0) {
|
||||||
return 0;
|
return 0;
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -1160,7 +1160,7 @@ class DateTime
|
||||||
if (!is_numeric($style)) {
|
if (!is_numeric($style)) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
} elseif (($style < 1) || ($style > 3)) {
|
} elseif (($style < 1) || ($style > 3)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$style = floor($style);
|
$style = floor($style);
|
||||||
|
|
||||||
|
@ -1169,7 +1169,7 @@ class DateTime
|
||||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -1236,7 +1236,7 @@ class DateTime
|
||||||
if (!is_numeric($method)) {
|
if (!is_numeric($method)) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
} elseif (($method < 1) || ($method > 2)) {
|
} elseif (($method < 1) || ($method > 2)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$method = floor($method);
|
$method = floor($method);
|
||||||
|
|
||||||
|
@ -1245,7 +1245,7 @@ class DateTime
|
||||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -1284,7 +1284,7 @@ class DateTime
|
||||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -1316,7 +1316,7 @@ class DateTime
|
||||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
|
@ -1359,7 +1359,7 @@ class DateTime
|
||||||
if ($timeValue >= 1) {
|
if ($timeValue >= 1) {
|
||||||
$timeValue = fmod($timeValue, 1);
|
$timeValue = fmod($timeValue, 1);
|
||||||
} elseif ($timeValue < 0.0) {
|
} elseif ($timeValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue);
|
$timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue);
|
||||||
|
|
||||||
|
@ -1400,7 +1400,7 @@ class DateTime
|
||||||
if ($timeValue >= 1) {
|
if ($timeValue >= 1) {
|
||||||
$timeValue = fmod($timeValue, 1);
|
$timeValue = fmod($timeValue, 1);
|
||||||
} elseif ($timeValue < 0.0) {
|
} elseif ($timeValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue);
|
$timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue);
|
||||||
|
|
||||||
|
@ -1441,7 +1441,7 @@ class DateTime
|
||||||
if ($timeValue >= 1) {
|
if ($timeValue >= 1) {
|
||||||
$timeValue = fmod($timeValue, 1);
|
$timeValue = fmod($timeValue, 1);
|
||||||
} elseif ($timeValue < 0.0) {
|
} elseif ($timeValue < 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue);
|
$timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue);
|
||||||
|
|
||||||
|
|
|
@ -830,7 +830,7 @@ class Engineering
|
||||||
if (strlen($xVal) <= $places) {
|
if (strlen($xVal) <= $places) {
|
||||||
return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10);
|
return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10);
|
||||||
} else {
|
} else {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +865,7 @@ class Engineering
|
||||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||||
$ord = floor($ord);
|
$ord = floor($ord);
|
||||||
if ($ord < 0) {
|
if ($ord < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abs($x) <= 30) {
|
if (abs($x) <= 30) {
|
||||||
|
@ -886,7 +886,7 @@ class Engineering
|
||||||
$fResult = -$fResult;
|
$fResult = -$fResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (is_nan($fResult)) ? Functions::NaN() : $fResult;
|
return (is_nan($fResult)) ? Functions::NAN() : $fResult;
|
||||||
}
|
}
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ class Engineering
|
||||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||||
$ord = floor($ord);
|
$ord = floor($ord);
|
||||||
if ($ord < 0) {
|
if ($ord < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$fResult = 0;
|
$fResult = 0;
|
||||||
|
@ -941,7 +941,7 @@ class Engineering
|
||||||
$fResult = -$fResult;
|
$fResult = -$fResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (is_nan($fResult)) ? Functions::NaN() : $fResult;
|
return (is_nan($fResult)) ? Functions::NAN() : $fResult;
|
||||||
}
|
}
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ class Engineering
|
||||||
|
|
||||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||||
if (($ord < 0) || ($x == 0.0)) {
|
if (($ord < 0) || ($x == 0.0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (floor($ord)) {
|
switch (floor($ord)) {
|
||||||
|
@ -1027,7 +1027,7 @@ class Engineering
|
||||||
$fBk = $fBkp;
|
$fBk = $fBkp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (is_nan($fBk)) ? Functions::NaN() : $fBk;
|
return (is_nan($fBk)) ? Functions::NAN() : $fBk;
|
||||||
}
|
}
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -1093,7 +1093,7 @@ class Engineering
|
||||||
|
|
||||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||||
if (($ord < 0) || ($x == 0.0)) {
|
if (($ord < 0) || ($x == 0.0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (floor($ord)) {
|
switch (floor($ord)) {
|
||||||
|
@ -1111,7 +1111,7 @@ class Engineering
|
||||||
$fBy = $fByp;
|
$fBy = $fByp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (is_nan($fBy)) ? Functions::NaN() : $fBy;
|
return (is_nan($fBy)) ? Functions::NAN() : $fBy;
|
||||||
}
|
}
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -1151,10 +1151,10 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (strlen($x) > 10) {
|
if (strlen($x) > 10) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (strlen($x) == 10) {
|
} elseif (strlen($x) == 10) {
|
||||||
// Two's Complement
|
// Two's Complement
|
||||||
$x = substr($x, -9);
|
$x = substr($x, -9);
|
||||||
|
@ -1205,10 +1205,10 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (strlen($x) > 10) {
|
if (strlen($x) > 10) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (strlen($x) == 10) {
|
} elseif (strlen($x) == 10) {
|
||||||
// Two's Complement
|
// Two's Complement
|
||||||
return str_repeat('F', 8).substr(strtoupper(dechex(bindec(substr($x, -9)))), -2);
|
return str_repeat('F', 8).substr(strtoupper(dechex(bindec(substr($x, -9)))), -2);
|
||||||
|
@ -1260,10 +1260,10 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (strlen($x) > 10) {
|
if (strlen($x) > 10) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (strlen($x) == 10) {
|
} elseif (strlen($x) == 10) {
|
||||||
// Two's Complement
|
// Two's Complement
|
||||||
return str_repeat('7', 7).substr(strtoupper(decoct(bindec(substr($x, -9)))), -3);
|
return str_repeat('7', 7).substr(strtoupper(decoct(bindec(substr($x, -9)))), -3);
|
||||||
|
@ -1324,7 +1324,7 @@ class Engineering
|
||||||
// Two's Complement
|
// Two's Complement
|
||||||
$r = substr($r, -10);
|
$r = substr($r, -10);
|
||||||
} elseif (strlen($r) > 11) {
|
} elseif (strlen($r) > 11) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::nbrConversionFormat($r, $places);
|
return self::nbrConversionFormat($r, $places);
|
||||||
|
@ -1482,7 +1482,7 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$binVal = decbin(hexdec($x));
|
$binVal = decbin(hexdec($x));
|
||||||
|
|
||||||
|
@ -1518,7 +1518,7 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return hexdec($x);
|
return hexdec($x);
|
||||||
}
|
}
|
||||||
|
@ -1566,7 +1566,7 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$octVal = decoct(hexdec($x));
|
$octVal = decoct(hexdec($x));
|
||||||
|
|
||||||
|
@ -1618,7 +1618,7 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$r = decbin(octdec($x));
|
$r = decbin(octdec($x));
|
||||||
|
|
||||||
|
@ -1654,7 +1654,7 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return octdec($x);
|
return octdec($x);
|
||||||
}
|
}
|
||||||
|
@ -1699,7 +1699,7 @@ class Engineering
|
||||||
}
|
}
|
||||||
$x = (string) $x;
|
$x = (string) $x;
|
||||||
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$hexVal = strtoupper(dechex(octdec($x)));
|
$hexVal = strtoupper(dechex(octdec($x)));
|
||||||
|
|
||||||
|
@ -2007,7 +2007,7 @@ class Engineering
|
||||||
$parsedComplex = self::parseComplex($complexNumber);
|
$parsedComplex = self::parseComplex($complexNumber);
|
||||||
|
|
||||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
|
$logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
|
||||||
|
@ -2039,7 +2039,7 @@ class Engineering
|
||||||
$parsedComplex = self::parseComplex($complexNumber);
|
$parsedComplex = self::parseComplex($complexNumber);
|
||||||
|
|
||||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||||
return log10($parsedComplex['real']);
|
return log10($parsedComplex['real']);
|
||||||
}
|
}
|
||||||
|
@ -2066,7 +2066,7 @@ class Engineering
|
||||||
$parsedComplex = self::parseComplex($complexNumber);
|
$parsedComplex = self::parseComplex($complexNumber);
|
||||||
|
|
||||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||||
return log($parsedComplex['real'], 2);
|
return log($parsedComplex['real'], 2);
|
||||||
}
|
}
|
||||||
|
@ -2166,7 +2166,7 @@ class Engineering
|
||||||
|
|
||||||
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
|
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
|
||||||
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
|
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
|
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
|
||||||
$parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
|
$parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
|
||||||
|
@ -2211,7 +2211,7 @@ class Engineering
|
||||||
|
|
||||||
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
|
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
|
||||||
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
|
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
|
} elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
|
||||||
$parsedComplex1['suffix'] = $parsedComplex2['suffix'];
|
$parsedComplex1['suffix'] = $parsedComplex2['suffix'];
|
||||||
}
|
}
|
||||||
|
@ -2288,7 +2288,7 @@ class Engineering
|
||||||
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
|
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
|
||||||
$activeSuffix = $parsedComplex['suffix'];
|
$activeSuffix = $parsedComplex['suffix'];
|
||||||
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
|
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
|
$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
|
||||||
$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
|
$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
|
||||||
|
|
|
@ -127,7 +127,7 @@ class Financial
|
||||||
$daysPerYear = (DateTime::isLeapYear($year)) ? 366 : 365;
|
$daysPerYear = (DateTime::isLeapYear($year)) ? 366 : 365;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return $daysPerYear;
|
return $daysPerYear;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ class Financial
|
||||||
$rate = (float) $rate;
|
$rate = (float) $rate;
|
||||||
$par = (float) $par;
|
$par = (float) $par;
|
||||||
if (($rate <= 0) || ($par <= 0)) {
|
if (($rate <= 0) || ($par <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis);
|
$daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis);
|
||||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||||
|
@ -246,7 +246,7 @@ class Financial
|
||||||
$rate = (float) $rate;
|
$rate = (float) $rate;
|
||||||
$par = (float) $par;
|
$par = (float) $par;
|
||||||
if (($rate <= 0) || ($par <= 0)) {
|
if (($rate <= 0) || ($par <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis);
|
$daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis);
|
||||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||||
|
@ -451,7 +451,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
||||||
|
@ -510,7 +510,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($basis) {
|
switch ($basis) {
|
||||||
|
@ -583,7 +583,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
||||||
|
@ -643,7 +643,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::couponFirstPeriodDate($settlement, $maturity, $frequency, true);
|
return self::couponFirstPeriodDate($settlement, $maturity, $frequency, true);
|
||||||
|
@ -700,7 +700,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$settlement = self::couponFirstPeriodDate($settlement, $maturity, $frequency, true);
|
$settlement = self::couponFirstPeriodDate($settlement, $maturity, $frequency, true);
|
||||||
|
@ -772,7 +772,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::couponFirstPeriodDate($settlement, $maturity, $frequency, false);
|
return self::couponFirstPeriodDate($settlement, $maturity, $frequency, false);
|
||||||
|
@ -811,7 +811,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($start < 1 || $start > $end) {
|
if ($start < 1 || $start > $end) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
|
@ -859,7 +859,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($start < 1 || $start > $end) {
|
if ($start < 1 || $start > $end) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
|
@ -919,7 +919,7 @@ class Financial
|
||||||
if ($cost == 0) {
|
if ($cost == 0) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
} elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) {
|
} elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
// Set Fixed Depreciation Rate
|
// Set Fixed Depreciation Rate
|
||||||
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
|
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
|
||||||
|
@ -985,7 +985,7 @@ class Financial
|
||||||
$period = (int) $period;
|
$period = (int) $period;
|
||||||
$factor = (float) $factor;
|
$factor = (float) $factor;
|
||||||
if (($cost <= 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($factor <= 0.0) || ($period > $life)) {
|
if (($cost <= 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($factor <= 0.0) || ($period > $life)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
// Set Fixed Depreciation Rate
|
// Set Fixed Depreciation Rate
|
||||||
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
|
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
|
||||||
|
@ -1045,7 +1045,7 @@ class Financial
|
||||||
$redemption = (float) $redemption;
|
$redemption = (float) $redemption;
|
||||||
$basis = (int) $basis;
|
$basis = (int) $basis;
|
||||||
if (($price <= 0) || ($redemption <= 0)) {
|
if (($price <= 0) || ($redemption <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
||||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||||
|
@ -1082,7 +1082,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (is_null($fractional_dollar) || $fraction < 0) {
|
if (is_null($fractional_dollar) || $fraction < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($fraction == 0) {
|
if ($fraction == 0) {
|
||||||
return Functions::DIV0();
|
return Functions::DIV0();
|
||||||
|
@ -1119,7 +1119,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (is_null($decimal_dollar) || $fraction < 0) {
|
if (is_null($decimal_dollar) || $fraction < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($fraction == 0) {
|
if ($fraction == 0) {
|
||||||
return Functions::DIV0();
|
return Functions::DIV0();
|
||||||
|
@ -1155,7 +1155,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($nominal_rate <= 0 || $npery < 1) {
|
if ($nominal_rate <= 0 || $npery < 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return pow((1 + $nominal_rate / $npery), $npery) - 1;
|
return pow((1 + $nominal_rate / $npery), $npery) - 1;
|
||||||
|
@ -1194,7 +1194,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
|
@ -1267,7 +1267,7 @@ class Financial
|
||||||
$redemption = (float) $redemption;
|
$redemption = (float) $redemption;
|
||||||
$basis = (int) $basis;
|
$basis = (int) $basis;
|
||||||
if (($investment <= 0) || ($redemption <= 0)) {
|
if (($investment <= 0) || ($redemption <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
||||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||||
|
@ -1308,7 +1308,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($per <= 0 || $per > $nper) {
|
if ($per <= 0 || $per > $nper) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
|
@ -1496,7 +1496,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($effect_rate <= 0 || $npery < 1) {
|
if ($effect_rate <= 0 || $npery < 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
|
@ -1526,18 +1526,18 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
if (!is_null($rate) && $rate != 0) {
|
if (!is_null($rate) && $rate != 0) {
|
||||||
if ($pmt == 0 && $pv == 0) {
|
if ($pmt == 0 && $pv == 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return log(($pmt * (1 + $rate * $type) / $rate - $fv) / ($pv + $pmt * (1 + $rate * $type) / $rate)) / log(1 + $rate);
|
return log(($pmt * (1 + $rate * $type) / $rate - $fv) / ($pv + $pmt * (1 + $rate * $type) / $rate)) / log(1 + $rate);
|
||||||
}
|
}
|
||||||
if ($pmt == 0) {
|
if ($pmt == 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return (-$pv -$fv) / $pmt;
|
return (-$pv -$fv) / $pmt;
|
||||||
}
|
}
|
||||||
|
@ -1592,7 +1592,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
|
@ -1627,7 +1627,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($per <= 0 || $per > $nper) {
|
if ($per <= 0 || $per > $nper) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
|
@ -1659,7 +1659,7 @@ class Financial
|
||||||
if (($settlement > $maturity) ||
|
if (($settlement > $maturity) ||
|
||||||
(!self::isValidFrequency($frequency)) ||
|
(!self::isValidFrequency($frequency)) ||
|
||||||
(($basis < 0) || ($basis > 4))) {
|
(($basis < 0) || ($basis > 4))) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$dsc = self::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
|
$dsc = self::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
|
||||||
|
@ -1711,7 +1711,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) {
|
if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) {
|
||||||
if (($discount <= 0) || ($redemption <= 0)) {
|
if (($discount <= 0) || ($redemption <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
||||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||||
|
@ -1757,7 +1757,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if (is_numeric($rate) && is_numeric($yield)) {
|
if (is_numeric($rate) && is_numeric($yield)) {
|
||||||
if (($rate <= 0) || ($yield <= 0)) {
|
if (($rate <= 0) || ($yield <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
||||||
if (!is_numeric($daysPerYear)) {
|
if (!is_numeric($daysPerYear)) {
|
||||||
|
@ -1812,7 +1812,7 @@ class Financial
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($type != 0 && $type != 1) {
|
if ($type != 0 && $type != 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
|
@ -1927,7 +1927,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) {
|
if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) {
|
||||||
if (($investment <= 0) || ($discount <= 0)) {
|
if (($investment <= 0) || ($discount <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
|
||||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||||
|
@ -1960,7 +1960,7 @@ class Financial
|
||||||
// Calculate
|
// Calculate
|
||||||
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life))) {
|
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life))) {
|
||||||
if ($life < 0) {
|
if ($life < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return ($cost - $salvage) / $life;
|
return ($cost - $salvage) / $life;
|
||||||
}
|
}
|
||||||
|
@ -1989,7 +1989,7 @@ class Financial
|
||||||
// Calculate
|
// Calculate
|
||||||
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period))) {
|
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period))) {
|
||||||
if (($life < 1) || ($period > $life)) {
|
if (($life < 1) || ($period > $life)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1));
|
return (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1));
|
||||||
}
|
}
|
||||||
|
@ -2061,7 +2061,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if (is_numeric($discount)) {
|
if (is_numeric($discount)) {
|
||||||
if ($discount <= 0) {
|
if ($discount <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||||
|
@ -2076,12 +2076,12 @@ class Financial
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($daysBetweenSettlementAndMaturity > 360) {
|
if ($daysBetweenSettlementAndMaturity > 360) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360));
|
$price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360));
|
||||||
if ($price <= 0) {
|
if ($price <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return $price;
|
return $price;
|
||||||
}
|
}
|
||||||
|
@ -2110,7 +2110,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if (is_numeric($price)) {
|
if (is_numeric($price)) {
|
||||||
if ($price <= 0) {
|
if ($price <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||||
|
@ -2125,7 +2125,7 @@ class Financial
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($daysBetweenSettlementAndMaturity > 360) {
|
if ($daysBetweenSettlementAndMaturity > 360) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity);
|
return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity);
|
||||||
|
@ -2143,7 +2143,7 @@ class Financial
|
||||||
$dates = Functions::flattenArray($dates);
|
$dates = Functions::flattenArray($dates);
|
||||||
$guess = Functions::flattenSingleValue($guess);
|
$guess = Functions::flattenSingleValue($guess);
|
||||||
if (count($values) != count($dates)) {
|
if (count($values) != count($dates)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an initial range, with a root somewhere between 0 and guess
|
// create an initial range, with a root somewhere between 0 and guess
|
||||||
|
@ -2220,7 +2220,7 @@ class Financial
|
||||||
$dates = Functions::flattenArray($dates);
|
$dates = Functions::flattenArray($dates);
|
||||||
$valCount = count($values);
|
$valCount = count($values);
|
||||||
if ($valCount != count($dates)) {
|
if ($valCount != count($dates)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((min($values) > 0) || (max($values) < 0)) {
|
if ((min($values) > 0) || (max($values) < 0)) {
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
|
@ -2267,7 +2267,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if (is_numeric($price) && is_numeric($redemption)) {
|
if (is_numeric($price) && is_numeric($redemption)) {
|
||||||
if (($price <= 0) || ($redemption <= 0)) {
|
if (($price <= 0) || ($redemption <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
||||||
if (!is_numeric($daysPerYear)) {
|
if (!is_numeric($daysPerYear)) {
|
||||||
|
@ -2318,7 +2318,7 @@ class Financial
|
||||||
// Validate
|
// Validate
|
||||||
if (is_numeric($rate) && is_numeric($price)) {
|
if (is_numeric($rate) && is_numeric($price)) {
|
||||||
if (($rate <= 0) || ($price <= 0)) {
|
if (($rate <= 0) || ($price <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
$daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis);
|
||||||
if (!is_numeric($daysPerYear)) {
|
if (!is_numeric($daysPerYear)) {
|
||||||
|
|
|
@ -222,7 +222,7 @@ class Functions
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #NUM!
|
* @return string #NUM!
|
||||||
*/
|
*/
|
||||||
public static function NaN()
|
public static function NAN()
|
||||||
{
|
{
|
||||||
return self::$errorCodes['num'];
|
return self::$errorCodes['num'];
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function ERROR_TYPE($value = '')
|
public static function errorType($value = '')
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_BLANK($value = null)
|
public static function isBlank($value = null)
|
||||||
{
|
{
|
||||||
if (!is_null($value)) {
|
if (!is_null($value)) {
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
@ -373,11 +373,11 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_ERR($value = '')
|
public static function isErr($value = '')
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
return self::IS_ERROR($value) && (!self::IS_NA($value));
|
return self::isError($value) && (!self::isNa(($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_ERROR($value = '')
|
public static function isError($value = '')
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_NA($value = '')
|
public static function isNa(($value = '')
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_EVEN($value = null)
|
public static function isEven($value = null)
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_ODD($value = null)
|
public static function isOdd($value = null)
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_NUMBER($value = null)
|
public static function isNumber($value = null)
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_LOGICAL($value = null)
|
public static function isLogical($value = null)
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
|
@ -489,11 +489,11 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_TEXT($value = null)
|
public static function isText($value = null)
|
||||||
{
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
return (is_string($value) && !self::IS_ERROR($value));
|
return (is_string($value) && !self::isError($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,9 +503,9 @@ class Functions
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_NONTEXT($value = null)
|
public static function isNonText($value = null)
|
||||||
{
|
{
|
||||||
return !self::IS_TEXT($value);
|
return !self::isText($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -273,6 +273,6 @@ class Logical
|
||||||
$testValue = (is_null($testValue)) ? '' : Functions::flattenSingleValue($testValue);
|
$testValue = (is_null($testValue)) ? '' : Functions::flattenSingleValue($testValue);
|
||||||
$errorpart = (is_null($errorpart)) ? '' : Functions::flattenSingleValue($errorpart);
|
$errorpart = (is_null($errorpart)) ? '' : Functions::flattenSingleValue($errorpart);
|
||||||
|
|
||||||
return self::STATEMENT_IF(Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
return self::STATEMENT_IF(Functions::isError($testValue), $errorpart, $testValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ class MathTrig
|
||||||
} elseif (self::SIGN($number) == self::SIGN($significance)) {
|
} elseif (self::SIGN($number) == self::SIGN($significance)) {
|
||||||
return ceil($number / $significance) * $significance;
|
return ceil($number / $significance) * $significance;
|
||||||
} else {
|
} else {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
|
@ -168,9 +168,9 @@ class MathTrig
|
||||||
|
|
||||||
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
|
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
|
||||||
if ($numObjs < $numInSet) {
|
if ($numObjs < $numInSet) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif ($numInSet < 0) {
|
} elseif ($numInSet < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
|
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
|
||||||
}
|
}
|
||||||
|
@ -233,12 +233,12 @@ class MathTrig
|
||||||
|
|
||||||
if (is_numeric($factVal)) {
|
if (is_numeric($factVal)) {
|
||||||
if ($factVal < 0) {
|
if ($factVal < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$factLoop = floor($factVal);
|
$factLoop = floor($factVal);
|
||||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||||
if ($factVal > $factLoop) {
|
if ($factVal > $factLoop) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ class MathTrig
|
||||||
if (is_numeric($factLoop)) {
|
if (is_numeric($factLoop)) {
|
||||||
$factLoop = floor($factLoop);
|
$factLoop = floor($factLoop);
|
||||||
if ($factVal < 0) {
|
if ($factVal < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$factorial = 1;
|
$factorial = 1;
|
||||||
while ($factLoop > 1) {
|
while ($factLoop > 1) {
|
||||||
|
@ -317,7 +317,7 @@ class MathTrig
|
||||||
} elseif (self::SIGN($number) == self::SIGN($significance)) {
|
} elseif (self::SIGN($number) == self::SIGN($significance)) {
|
||||||
return floor($number / $significance) * $significance;
|
return floor($number / $significance) * $significance;
|
||||||
} else {
|
} else {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ class MathTrig
|
||||||
} elseif ($value == 0) {
|
} elseif ($value == 0) {
|
||||||
continue;
|
continue;
|
||||||
} elseif ($value < 0) {
|
} elseif ($value < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$myFactors = self::factors($value);
|
$myFactors = self::factors($value);
|
||||||
$myCountedFactors = array_count_values($myFactors);
|
$myCountedFactors = array_count_values($myFactors);
|
||||||
|
@ -459,7 +459,7 @@ class MathTrig
|
||||||
if ($value == 0) {
|
if ($value == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} elseif ($value < 0) {
|
} elseif ($value < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$myFactors = self::factors(floor($value));
|
$myFactors = self::factors(floor($value));
|
||||||
$myCountedFactors = array_count_values($myFactors);
|
$myCountedFactors = array_count_values($myFactors);
|
||||||
|
@ -507,7 +507,7 @@ class MathTrig
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
}
|
}
|
||||||
if (($base <= 0) || ($number <= 0)) {
|
if (($base <= 0) || ($number <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return log($number, $base);
|
return log($number, $base);
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ class MathTrig
|
||||||
$multiplier = 1 / $multiple;
|
$multiplier = 1 / $multiple;
|
||||||
return round($number * $multiplier) / $multiplier;
|
return round($number * $multiplier) / $multiplier;
|
||||||
}
|
}
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return Functions::VALUE();
|
return Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -747,7 +747,7 @@ class MathTrig
|
||||||
// Is it a numeric value?
|
// Is it a numeric value?
|
||||||
if (is_numeric($arg)) {
|
if (is_numeric($arg)) {
|
||||||
if ($arg < 1) {
|
if ($arg < 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$summer += floor($arg);
|
$summer += floor($arg);
|
||||||
$divisor *= self::FACT($arg);
|
$divisor *= self::FACT($arg);
|
||||||
|
@ -814,14 +814,14 @@ class MathTrig
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if ($x == 0.0 && $y == 0.0) {
|
if ($x == 0.0 && $y == 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif ($x == 0.0 && $y < 0.0) {
|
} elseif ($x == 0.0 && $y < 0.0) {
|
||||||
return Functions::DIV0();
|
return Functions::DIV0();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
$result = pow($x, $y);
|
$result = pow($x, $y);
|
||||||
return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NaN();
|
return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1087,7 +1087,7 @@ class MathTrig
|
||||||
|
|
||||||
if (is_numeric($number)) {
|
if (is_numeric($number)) {
|
||||||
if ($number < 0) {
|
if ($number < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return sqrt($number * M_PI) ;
|
return sqrt($number * M_PI) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,7 +743,7 @@ class Statistical
|
||||||
}
|
}
|
||||||
return $returnValue / $aCount;
|
return $returnValue / $aCount;
|
||||||
}
|
}
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -906,7 +906,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
||||||
if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) {
|
if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($rMin > $rMax) {
|
if ($rMin > $rMax) {
|
||||||
$tmp = $rMin;
|
$tmp = $rMin;
|
||||||
|
@ -945,7 +945,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
||||||
if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
|
if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($rMin > $rMax) {
|
if ($rMin > $rMax) {
|
||||||
$tmp = $rMin;
|
$tmp = $rMin;
|
||||||
|
@ -1002,10 +1002,10 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) {
|
if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) {
|
||||||
if (($value < 0) || ($value > $trials)) {
|
if (($value < 0) || ($value > $trials)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (($probability < 0) || ($probability > 1)) {
|
if (($probability < 0) || ($probability > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
|
@ -1039,13 +1039,13 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($degrees))) {
|
if ((is_numeric($value)) && (is_numeric($degrees))) {
|
||||||
if ($degrees < 1) {
|
if ($degrees < 1) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($value < 0) {
|
if ($value < 0) {
|
||||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return 1 - (self::incompleteGamma($degrees/2, $value/2) / self::gamma($degrees/2));
|
return 1 - (self::incompleteGamma($degrees/2, $value/2) / self::gamma($degrees/2));
|
||||||
}
|
}
|
||||||
|
@ -1128,10 +1128,10 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) {
|
if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) {
|
||||||
if (($alpha <= 0) || ($alpha >= 1)) {
|
if (($alpha <= 0) || ($alpha >= 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (($stdDev <= 0) || ($size < 1)) {
|
if (($stdDev <= 0) || ($size < 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return self::NORMSINV(1 - $alpha / 2) * $stdDev / sqrt($size);
|
return self::NORMSINV(1 - $alpha / 2) * $stdDev / sqrt($size);
|
||||||
}
|
}
|
||||||
|
@ -1355,11 +1355,11 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) {
|
if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) {
|
||||||
if ($trials < 0) {
|
if ($trials < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (($probability < 0) || ($probability > 1)) {
|
} elseif (($probability < 0) || ($probability > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (($alpha < 0) || ($alpha > 1)) {
|
} elseif (($alpha < 0) || ($alpha > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif ($alpha <= 0.5) {
|
} elseif ($alpha <= 0.5) {
|
||||||
$t = sqrt(log(1 / ($alpha * $alpha)));
|
$t = sqrt(log(1 / ($alpha * $alpha)));
|
||||||
$trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t));
|
$trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t));
|
||||||
|
@ -1494,7 +1494,7 @@ class Statistical
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
if (is_null($returnValue)) {
|
if (is_null($returnValue)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} else {
|
} else {
|
||||||
return $returnValue;
|
return $returnValue;
|
||||||
}
|
}
|
||||||
|
@ -1523,7 +1523,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($lambda))) {
|
if ((is_numeric($value)) && (is_numeric($lambda))) {
|
||||||
if (($value < 0) || ($lambda < 0)) {
|
if (($value < 0) || ($lambda < 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
|
@ -1553,7 +1553,7 @@ class Statistical
|
||||||
|
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
if (($value <= -1) || ($value >= 1)) {
|
if (($value <= -1) || ($value >= 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return 0.5 * log((1+$value)/(1-$value));
|
return 0.5 * log((1+$value)/(1-$value));
|
||||||
}
|
}
|
||||||
|
@ -1634,7 +1634,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($a)) && (is_numeric($b))) {
|
if ((is_numeric($value)) && (is_numeric($a)) && (is_numeric($b))) {
|
||||||
if (($value < 0) || ($a <= 0) || ($b <= 0)) {
|
if (($value < 0) || ($a <= 0) || ($b <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
|
@ -1667,7 +1667,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) {
|
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) {
|
||||||
if (($alpha <= 0) || ($beta <= 0) || ($probability < 0) || ($probability > 1)) {
|
if (($alpha <= 0) || ($beta <= 0) || ($probability < 0) || ($probability > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$xLo = 0;
|
$xLo = 0;
|
||||||
|
@ -1724,7 +1724,7 @@ class Statistical
|
||||||
|
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
if ($value <= 0) {
|
if ($value <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return log(self::gamma($value));
|
return log(self::gamma($value));
|
||||||
}
|
}
|
||||||
|
@ -1758,7 +1758,7 @@ class Statistical
|
||||||
return pow($aMean, (1 / $aCount));
|
return pow($aMean, (1 / $aCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1816,14 +1816,14 @@ class Statistical
|
||||||
// Loop through arguments
|
// Loop through arguments
|
||||||
$aArgs = Functions::flattenArray(func_get_args());
|
$aArgs = Functions::flattenArray(func_get_args());
|
||||||
if (self::MIN($aArgs) < 0) {
|
if (self::MIN($aArgs) < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$aCount = 0;
|
$aCount = 0;
|
||||||
foreach ($aArgs as $arg) {
|
foreach ($aArgs as $arg) {
|
||||||
// Is it a numeric value?
|
// Is it a numeric value?
|
||||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||||
if ($arg <= 0) {
|
if ($arg <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (is_null($returnValue)) {
|
if (is_null($returnValue)) {
|
||||||
$returnValue = (1 / $arg);
|
$returnValue = (1 / $arg);
|
||||||
|
@ -1865,13 +1865,13 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) {
|
if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) {
|
||||||
if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) {
|
if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (($sampleNumber <= 0) || ($sampleNumber > $populationNumber)) {
|
if (($sampleNumber <= 0) || ($sampleNumber > $populationNumber)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) {
|
if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return MathTrig::COMBIN($populationSuccesses, $sampleSuccesses) *
|
return MathTrig::COMBIN($populationSuccesses, $sampleSuccesses) *
|
||||||
MathTrig::COMBIN($populationNumber - $populationSuccesses, $sampleNumber - $sampleSuccesses) /
|
MathTrig::COMBIN($populationNumber - $populationSuccesses, $sampleNumber - $sampleSuccesses) /
|
||||||
|
@ -1984,7 +1984,7 @@ class Statistical
|
||||||
$count = self::COUNT($mArgs);
|
$count = self::COUNT($mArgs);
|
||||||
$entry = floor(--$entry);
|
$entry = floor(--$entry);
|
||||||
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
|
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
rsort($mArgs);
|
rsort($mArgs);
|
||||||
return $mArgs[$entry];
|
return $mArgs[$entry];
|
||||||
|
@ -2081,7 +2081,7 @@ class Statistical
|
||||||
|
|
||||||
foreach ($yValues as $value) {
|
foreach ($yValues as $value) {
|
||||||
if ($value <= 0.0) {
|
if ($value <= 0.0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2141,7 +2141,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
||||||
if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) {
|
if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return exp($mean + $stdDev * self::NORMSINV($probability));
|
return exp($mean + $stdDev * self::NORMSINV($probability));
|
||||||
}
|
}
|
||||||
|
@ -2168,7 +2168,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
||||||
if (($value <= 0) || ($stdDev <= 0)) {
|
if (($value <= 0) || ($stdDev <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return self::NORMSDIST((log($value) - $mean) / $stdDev);
|
return self::NORMSDIST((log($value) - $mean) / $stdDev);
|
||||||
}
|
}
|
||||||
|
@ -2307,7 +2307,7 @@ class Statistical
|
||||||
*/
|
*/
|
||||||
public static function MEDIAN()
|
public static function MEDIAN()
|
||||||
{
|
{
|
||||||
$returnValue = Functions::NaN();
|
$returnValue = Functions::NAN();
|
||||||
|
|
||||||
$mArgs = array();
|
$mArgs = array();
|
||||||
// Loop through arguments
|
// Loop through arguments
|
||||||
|
@ -2548,13 +2548,13 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) {
|
if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) {
|
||||||
if (($failures < 0) || ($successes < 1)) {
|
if (($failures < 0) || ($successes < 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
} elseif (($probability < 0) || ($probability > 1)) {
|
} elseif (($probability < 0) || ($probability > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||||
if (($failures + $successes - 1) <= 0) {
|
if (($failures + $successes - 1) <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures));
|
return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures));
|
||||||
|
@ -2585,7 +2585,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
||||||
if ($stdDev < 0) {
|
if ($stdDev < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
|
@ -2618,10 +2618,10 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
||||||
if (($probability < 0) || ($probability > 1)) {
|
if (($probability < 0) || ($probability > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ($stdDev < 0) {
|
if ($stdDev < 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return (self::inverseNcdf($probability) * $stdDev) + $mean;
|
return (self::inverseNcdf($probability) * $stdDev) + $mean;
|
||||||
}
|
}
|
||||||
|
@ -2684,7 +2684,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($entry)) && (!is_string($entry))) {
|
if ((is_numeric($entry)) && (!is_string($entry))) {
|
||||||
if (($entry < 0) || ($entry > 1)) {
|
if (($entry < 0) || ($entry > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$mArgs = array();
|
$mArgs = array();
|
||||||
foreach ($aArgs as $arg) {
|
foreach ($aArgs as $arg) {
|
||||||
|
@ -2736,7 +2736,7 @@ class Statistical
|
||||||
sort($valueSet, SORT_NUMERIC);
|
sort($valueSet, SORT_NUMERIC);
|
||||||
$valueCount = count($valueSet);
|
$valueCount = count($valueSet);
|
||||||
if ($valueCount == 0) {
|
if ($valueCount == 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
|
|
||||||
$valueAdjustor = $valueCount - 1;
|
$valueAdjustor = $valueCount - 1;
|
||||||
|
@ -2780,7 +2780,7 @@ class Statistical
|
||||||
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
|
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
|
||||||
$numInSet = floor($numInSet);
|
$numInSet = floor($numInSet);
|
||||||
if ($numObjs < $numInSet) {
|
if ($numObjs < $numInSet) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return round(MathTrig::FACT($numObjs) / MathTrig::FACT($numObjs - $numInSet));
|
return round(MathTrig::FACT($numObjs) / MathTrig::FACT($numObjs - $numInSet));
|
||||||
}
|
}
|
||||||
|
@ -2808,7 +2808,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($mean))) {
|
if ((is_numeric($value)) && (is_numeric($mean))) {
|
||||||
if (($value < 0) || ($mean <= 0)) {
|
if (($value < 0) || ($mean <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
|
@ -2850,7 +2850,7 @@ class Statistical
|
||||||
if ((is_numeric($entry)) && (!is_string($entry))) {
|
if ((is_numeric($entry)) && (!is_string($entry))) {
|
||||||
$entry /= 4;
|
$entry /= 4;
|
||||||
if (($entry < 0) || ($entry > 1)) {
|
if (($entry < 0) || ($entry > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return self::PERCENTILE($aArgs, $entry);
|
return self::PERCENTILE($aArgs, $entry);
|
||||||
}
|
}
|
||||||
|
@ -3021,7 +3021,7 @@ class Statistical
|
||||||
$count = self::COUNT($mArgs);
|
$count = self::COUNT($mArgs);
|
||||||
$entry = floor(--$entry);
|
$entry = floor(--$entry);
|
||||||
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
|
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
sort($mArgs);
|
sort($mArgs);
|
||||||
return $mArgs[$entry];
|
return $mArgs[$entry];
|
||||||
|
@ -3048,7 +3048,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
||||||
if ($stdDev <= 0) {
|
if ($stdDev <= 0) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
return ($value - $mean) / $stdDev ;
|
return ($value - $mean) / $stdDev ;
|
||||||
}
|
}
|
||||||
|
@ -3299,7 +3299,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) {
|
if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) {
|
||||||
if (($value < 0) || ($degrees < 1) || ($tails < 1) || ($tails > 2)) {
|
if (($value < 0) || ($degrees < 1) || ($tails < 1) || ($tails > 2)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
// tdist, which finds the probability that corresponds to a given value
|
// tdist, which finds the probability that corresponds to a given value
|
||||||
// of t with k degrees of freedom. This algorithm is translated from a
|
// of t with k degrees of freedom. This algorithm is translated from a
|
||||||
|
@ -3458,7 +3458,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($percent)) && (!is_string($percent))) {
|
if ((is_numeric($percent)) && (!is_string($percent))) {
|
||||||
if (($percent < 0) || ($percent > 1)) {
|
if (($percent < 0) || ($percent > 1)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$mArgs = array();
|
$mArgs = array();
|
||||||
foreach ($aArgs as $arg) {
|
foreach ($aArgs as $arg) {
|
||||||
|
@ -3691,7 +3691,7 @@ class Statistical
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) {
|
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) {
|
||||||
if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) {
|
if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ class TextData
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (!is_numeric($value) || !is_numeric($decimals)) {
|
if (!is_numeric($value) || !is_numeric($decimals)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$decimals = floor($decimals);
|
$decimals = floor($decimals);
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ class TextData
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (!is_numeric($value) || !is_numeric($decimals)) {
|
if (!is_numeric($value) || !is_numeric($decimals)) {
|
||||||
return Functions::NaN();
|
return Functions::NAN();
|
||||||
}
|
}
|
||||||
$decimals = floor($decimals);
|
$decimals = floor($decimals);
|
||||||
|
|
||||||
|
|
|
@ -532,7 +532,7 @@ class Matrix
|
||||||
if ($validValues) {
|
if ($validValues) {
|
||||||
$this->A[$i][$j] += $value;
|
$this->A[$i][$j] += $value;
|
||||||
} else {
|
} else {
|
||||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ class Matrix
|
||||||
if ($validValues) {
|
if ($validValues) {
|
||||||
$this->A[$i][$j] -= $value;
|
$this->A[$i][$j] -= $value;
|
||||||
} else {
|
} else {
|
||||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ class Matrix
|
||||||
if ($validValues) {
|
if ($validValues) {
|
||||||
$this->A[$i][$j] *= $value;
|
$this->A[$i][$j] *= $value;
|
||||||
} else {
|
} else {
|
||||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,7 +782,7 @@ class Matrix
|
||||||
$M->set($i, $j, $this->A[$i][$j] / $value);
|
$M->set($i, $j, $this->A[$i][$j] / $value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$M->set($i, $j, PHPExcel_Calculation_Functions::NaN());
|
$M->set($i, $j, PHPExcel_Calculation_Functions::NAN());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1058,7 @@ class Matrix
|
||||||
if ($validValues) {
|
if ($validValues) {
|
||||||
$this->A[$i][$j] = pow($this->A[$i][$j], $value);
|
$this->A[$i][$j] = pow($this->A[$i][$j], $value);
|
||||||
} else {
|
} else {
|
||||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals('#N/A', $result);
|
$this->assertEquals('#N/A', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNaN()
|
public function testNAN()
|
||||||
{
|
{
|
||||||
$result = \PHPExcel\Calculation\Functions::NaN();
|
$result = \PHPExcel\Calculation\Functions::NAN();
|
||||||
$this->assertEquals('#NUM!', $result);
|
$this->assertEquals('#NUM!', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_BLANK'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isBlank'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,13 +115,13 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','ERROR_TYPE'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','errorType'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function providerERROR_TYPE()
|
public function providerERROR_TYPE()
|
||||||
{
|
{
|
||||||
return new \testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data');
|
return new \testDataFileIterator('rawTestData/Calculation/Functions/errorType.data');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +131,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_LOGICAL'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isLogical'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_NA'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isError('), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_NUMBER'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isNumber'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_TEXT'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isText'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_NONTEXT'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isNonText'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_EVEN'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isEven'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($args);
|
$expectedResult = array_pop($args);
|
||||||
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_ODD'), $args);
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isOdd'), $args);
|
||||||
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue