本文整理汇总了PHP中PHPExcel_Calculation_Functions::DIV0方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Calculation_Functions::DIV0方法的具体用法?PHP PHPExcel_Calculation_Functions::DIV0怎么用?PHP PHPExcel_Calculation_Functions::DIV0使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Calculation_Functions
的用法示例。
在下文中一共展示了PHPExcel_Calculation_Functions::DIV0方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DOLLARFR
/**
* DOLLARFR
*
* Converts a dollar price expressed as a decimal number into a dollar price
* expressed as a fraction.
* Fractional dollar numbers are sometimes used for security prices.
*
* Excel Function:
* DOLLARFR(decimal_dollar,fraction)
*
* @access public
* @category Financial Functions
* @param float $decimal_dollar Decimal Dollar
* @param integer $fraction Fraction
* @return float
*/
public static function DOLLARFR($decimal_dollar = Null, $fraction = 0)
{
$decimal_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($decimal_dollar);
$fraction = (int) PHPExcel_Calculation_Functions::flattenSingleValue($fraction);
// Validate parameters
if (is_null($decimal_dollar) || $fraction < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($fraction == 0) {
return PHPExcel_Calculation_Functions::DIV0();
}
$dollars = floor($decimal_dollar);
$cents = fmod($decimal_dollar, 1);
$cents *= $fraction;
$cents *= pow(10, -ceil(log10($fraction)));
return $dollars + $cents;
}
示例2: VARPA
/**
* VARPA
*
* Calculates variance based on the entire population, including numbers, text, and logical values
*
* Excel Function:
* VARPA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function VARPA()
{
// Return value
$returnValue = PHPExcel_Calculation_Functions::DIV0();
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if (is_string($arg) && PHPExcel_Calculation_Functions::isValue($k)) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif (is_string($arg) && !PHPExcel_Calculation_Functions::isMatrixValue($k)) {
} else {
// Is it a numeric value?
if (is_numeric($arg) || is_bool($arg) || is_string($arg) & $arg != '') {
if (is_bool($arg)) {
$arg = (int) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
$summerA += $arg * $arg;
$summerB += $arg;
++$aCount;
}
}
}
// Return
if ($aCount > 0) {
$summerA *= $aCount;
$summerB *= $summerB;
$returnValue = ($summerA - $summerB) / ($aCount * $aCount);
}
return $returnValue;
}
示例3: POWER
/**
* POWER
*
* Computes x raised to the power y.
*
* @param float $x
* @param float $y
* @return float
*/
public static function POWER($x = 0, $y = 2)
{
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$y = PHPExcel_Calculation_Functions::flattenSingleValue($y);
// Validate parameters
if ($x == 0.0 && $y == 0.0) {
return PHPExcel_Calculation_Functions::NaN();
} elseif ($x == 0.0 && $y < 0.0) {
return PHPExcel_Calculation_Functions::DIV0();
}
// Return
$result = pow($x, $y);
return !is_nan($result) && !is_infinite($result) ? $result : PHPExcel_Calculation_Functions::NaN();
}
示例4: testDIV0
public function testDIV0()
{
$result = PHPExcel_Calculation_Functions::DIV0();
$this->assertEquals('#DIV/0!', $result);
}
示例5: POWER
/**
* POWER
*
* Computes x raised to the power y.
*
* @param float $x
* @param float $y
* @return float
*/
public static function POWER($x = 0, $y = 2)
{
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$y = PHPExcel_Calculation_Functions::flattenSingleValue($y);
// Validate parameters
if ($x == 0 && $y <= 0) {
return PHPExcel_Calculation_Functions::DIV0();
}
// Return
return pow($x, $y);
}