You are here

public static function PHPExcel_Calculation_MathTrig::FACTDOUBLE in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::FACTDOUBLE()

* FACTDOUBLE * * Returns the double factorial of a number. * * Excel Function: * FACTDOUBLE(factVal) * * @access public * @category Mathematical and Trigonometric Functions *

Parameters

float $factVal Factorial Value: * @return int Double Factorial

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php, line 277

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function FACTDOUBLE($factVal) {
  $factLoop = PHPExcel_Calculation_Functions::flattenSingleValue($factVal);
  if (is_numeric($factLoop)) {
    $factLoop = floor($factLoop);
    if ($factVal < 0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    $factorial = 1;
    while ($factLoop > 1) {
      $factorial *= $factLoop--;
      --$factLoop;
    }
    return $factorial;
  }
  return PHPExcel_Calculation_Functions::VALUE();
}