You are here

public static function PHPExcel_Calculation_Engineering::IMSUB in Loft Data Grids 7.2

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

* IMSUB * * Returns the difference of two complex numbers in x + yi or x + yj text format. * * Excel Function: * IMSUB(complexNumber1,complexNumber2) * *

Parameters

string $complexNumber1 The complex number from which to subtract complexNumber2.: * @param string $complexNumber2 The complex number to subtract from complexNumber1. * @return string

File

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

Class

PHPExcel_Calculation_Engineering
PHPExcel_Calculation_Engineering

Code

public static function IMSUB($complexNumber1, $complexNumber2) {
  $complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1);
  $complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2);
  $parsedComplex1 = self::_parseComplex($complexNumber1);
  $parsedComplex2 = self::_parseComplex($complexNumber2);
  if ($parsedComplex1['suffix'] != '' && $parsedComplex2['suffix'] != '' && $parsedComplex1['suffix'] != $parsedComplex2['suffix']) {
    return PHPExcel_Calculation_Functions::NaN();
  }
  elseif ($parsedComplex1['suffix'] == '' && $parsedComplex2['suffix'] != '') {
    $parsedComplex1['suffix'] = $parsedComplex2['suffix'];
  }
  $d1 = $parsedComplex1['real'] - $parsedComplex2['real'];
  $d2 = $parsedComplex1['imaginary'] - $parsedComplex2['imaginary'];
  return self::COMPLEX($d1, $d2, $parsedComplex1['suffix']);
}