You are here

public static function PHPExcel_Calculation_Engineering::COMPLEX in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php \PHPExcel_Calculation_Engineering::COMPLEX()

* COMPLEX * * Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj. * * Excel Function: * COMPLEX(realNumber,imaginary[,places]) * * @access public * @category Engineering Functions *

Parameters

float $realNumber The real coefficient of the complex number.: * @param float $imaginary The imaginary coefficient of the complex number. * @param string $suffix The suffix for the imaginary component of the complex number. * If omitted, the suffix is assumed to be "i". * @return string

10 calls to PHPExcel_Calculation_Engineering::COMPLEX()
PHPExcel_Calculation_Engineering::IMCONJUGATE in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
* IMCONJUGATE * * Returns the complex conjugate of a complex number in x + yi or x + yj text format. * * Excel Function: * IMCONJUGATE(complexNumber) * *
PHPExcel_Calculation_Engineering::IMCOS in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
* IMCOS * * Returns the cosine of a complex number in x + yi or x + yj text format. * * Excel Function: * IMCOS(complexNumber) * *
PHPExcel_Calculation_Engineering::IMEXP in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
* IMEXP * * Returns the exponential of a complex number in x + yi or x + yj text format. * * Excel Function: * IMEXP(complexNumber) * *
PHPExcel_Calculation_Engineering::IMLN in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
* IMLN * * Returns the natural logarithm of a complex number in x + yi or x + yj text format. * * Excel Function: * IMLN(complexNumber) * *
PHPExcel_Calculation_Engineering::IMPOWER in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
* IMPOWER * * Returns a complex number in x + yi or x + yj text format raised to a power. * * Excel Function: * IMPOWER(complexNumber,realNumber) * *

... See full list

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php, line 1640

Class

PHPExcel_Calculation_Engineering
PHPExcel_Calculation_Engineering

Code

public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') {
  $realNumber = is_null($realNumber) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
  $imaginary = is_null($imaginary) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary);
  $suffix = is_null($suffix) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix);
  if (is_numeric($realNumber) && is_numeric($imaginary) && ($suffix == 'i' || $suffix == 'j' || $suffix == '')) {
    $realNumber = (double) $realNumber;
    $imaginary = (double) $imaginary;
    if ($suffix == '') {
      $suffix = 'i';
    }
    if ($realNumber == 0.0) {
      if ($imaginary == 0.0) {
        return (string) '0';
      }
      elseif ($imaginary == 1.0) {
        return (string) $suffix;
      }
      elseif ($imaginary == -1.0) {
        return (string) '-' . $suffix;
      }
      return (string) $imaginary . $suffix;
    }
    elseif ($imaginary == 0.0) {
      return (string) $realNumber;
    }
    elseif ($imaginary == 1.0) {
      return (string) $realNumber . '+' . $suffix;
    }
    elseif ($imaginary == -1.0) {
      return (string) $realNumber . '-' . $suffix;
    }
    if ($imaginary > 0) {
      $imaginary = (string) '+' . $imaginary;
    }
    return (string) $realNumber . $imaginary . $suffix;
  }
  return PHPExcel_Calculation_Functions::VALUE();
}