You are here

public static function PHPExcel_Calculation_MathTrig::POWER in Loft Data Grids 7.2

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

* POWER * * Computes x raised to the power y. * *

Parameters

float $x: * @param float $y * @return float

File

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

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

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();
}