計算式を逆ポーランド記法に変換します。

@param	string	$numerical_formula	計算式
@return	string	逆ポーランド記法化された計算式
183119
public static function InfixToPostfix ($numerical_formula) {
		if (preg_match_all("/[\(\)\+\-\/\*%]|\d+\.\d+|[0]|[1-9][0-9]*/", $numerical_formula, $postfix_formula) === 0) {
			return $numerical_formula;
		}

		$postfix_formula = $postfix_formula[0];

		// 数値の符号対応（マイナスの数値が渡ってきた場合＝演算子が続いた場合、符号と判断し、結合してセットする）
		$op_adjuster = [];
		for ($i = 0, $postfix_formula_length = count($postfix_formula); $i < $postfix_formula_length; $i++) {
			if ($i == 0 && static::IsOperator($postfix_formula[$i])) {
				$op_adjuster[] = ($postfix_formula[$i] . $postfix_formula[++$i]);
			} else if (static::IsOperator($postfix_formula[$i]) && static::IsOperator($postfix_formula[$i + 1]) && $i + 2 < $postfix_formula_length) {
				$op_adjuster[] = ($postfix_formula[$i]);
				$op_adjuster[] = ($postfix_formula[++$i] . $postfix_formula[++$i]);
			} else {
				$op_adjuster[] = ($postfix_formula[$i]);
			}
		}
		$postfix_formula = $op_adjuster;

		$stack = [];
		$polish = [];
		$top = '';

		foreach ($postfix_formula as $chunk) {
			if ($chunk == '(') {
				$stack[] = $chunk;
			} else if ($chunk == ')') {
				while (count($stack) != 0) {
					$top = array_slice($stack, -1)[0];
					if ($top != '(') {
						$polish[] = array_pop($stack);
					} else {
						break;
					}
				}
				array_pop($stack);	// skip '('
			} else {
				while (count($stack) != 0) {
					$top = array_slice($stack, -1)[0];
					if (static::GetOperatorPriority($chunk) <= static::GetOperatorPriority($top)) {
						$polish[] = array_pop($stack);
					} else {
						break;
					}
				}
				$stack[] = $chunk;
			}
		}
		while (count($stack) != 0) {
			$polish[] = array_pop($stack);
		}
		return $polish;
	}
1252721
function _convertNumber($num)
	{
		// Integer in the range 0..2**16-1
		if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) {
			return pack("Cv", $this->ptg['ptgInt'], $num);
		} else { // A float
			if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
				$num = strrev($num);
			}
			return pack("Cd", $this->ptg['ptgNum'], $num);
		}
	}
11080
public static function localize($formula) {
        $formula = str_replace('.', '$', $formula); // temp placeholder
        $formula = str_replace(',', get_string('listsep', 'langconfig'), $formula);
        $formula = str_replace('$', get_string('decsep', 'langconfig'), $formula);
        return $formula;
    }
907174
public function getMethodId($context_self = null)
    {
        if ($this->function instanceof ClassMethod) {
            $function_name = (string)$this->function->name;

            return ($context_self ?: $this->source->getFQCLN()) . '::' . strtolower($function_name);
        }

        if ($this->function instanceof Function_) {
            $namespace = $this->source->getNamespace();

            return ($namespace ? strtolower($namespace) . '\\' : '') . strtolower($this->function->name->name);
        }

        return $this->getFilePath()
            . ':' . $this->function->getLine()
            . ':' . (int)$this->function->getAttribute('startFilePos')
            . ':-:closure';
    }
29088
public static function CONCATENATE() {
		// Return value
		$returnValue = '';

		// Loop through arguments
		$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
		foreach ($aArgs as $arg) {
			if (is_bool($arg)) {
				if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
					$arg = (int) $arg;
				} else {
					$arg = ($arg) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
				}
			}
			$returnValue .= $arg;
		}

		// Return
		return $returnValue;
	}
462478
def strnum(prefix: str, num: int, suffix: str = "") -> str:
    
    return "{}{}{}".format(prefix, num, suffix)
18093
public function _validation_numeric_between($val, $min_val, $max_val)
	{
		return $this->_empty($val) or (floatval($val) >= floatval($min_val) and floatval($val) <= floatval($max_val));
	}
920111
public static String stringFor(int result)
    {
        switch (result)
        {
            case NVRTC_SUCCESS                                     : return "NVRTC_SUCCESS";
            case NVRTC_ERROR_OUT_OF_MEMORY                         : return "NVRTC_ERROR_OUT_OF_MEMORY";
            case NVRTC_ERROR_PROGRAM_CREATION_FAILURE              : return "NVRTC_ERROR_PROGRAM_CREATION_FAILURE";
            case NVRTC_ERROR_INVALID_INPUT                         : return "NVRTC_ERROR_INVALID_INPUT";
            case NVRTC_ERROR_INVALID_PROGRAM                       : return "NVRTC_ERROR_INVALID_PROGRAM";
            case NVRTC_ERROR_INVALID_OPTION                        : return "NVRTC_ERROR_INVALID_OPTION";
            case NVRTC_ERROR_COMPILATION                           : return "NVRTC_ERROR_COMPILATION";
            case NVRTC_ERROR_BUILTIN_OPERATION_FAILURE             : return "NVRTC_ERROR_BUILTIN_OPERATION_FAILURE";
            case NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION : return "NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION";
            case NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION   : return "NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION";
            case NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID             : return "NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID";
            case NVRTC_ERROR_INTERNAL_ERROR                        : return "NVRTC_ERROR_INTERNAL_ERROR";
            case JCUDA_INTERNAL_ERROR                              : return "JCUDA_INTERNAL_ERROR";
        }
        return "INVALID nvrtcResult: "+result;
    }
1129396
private static function num2str(int $num):string
    {
        if ($num > 0 && $num < 160) {
            return chr($num);
        } elseif ($num < -20319 || $num > -10247) {
            return '';
        } else {
            $total = sizeof(self::$lib) - 1;
            for ($i = $total; $i >= 0; $i--) {
                if (self::$lib[$i][1] <= $num) {
                    break;
                }
            }
            return self::$lib[$i][0];
        }
    }
709485
private static function nbrConversionFormat($xVal, $places)
    {
        if (!is_null($places)) {
            if (strlen($xVal) <= $places) {
                return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10);
            } else {
                return PHPExcel_Calculation_Functions::NaN();
            }
        }

        return substr($xVal, -10);
    }
51986
private function writePhpFunction(): string
    {
        $phpFunction = $this->method->getPhpDoc();
        if ($this->method->getReturnType() !== 'mixed' && $this->method->getReturnType() !== 'resource') {
            $returnType = ': ' . $this->method->getReturnType();
        } else {
            $returnType = '';
        }
        $returnStatement = '';
        if ($this->method->getReturnType() !== 'void') {
            $returnStatement = "    return \$result;\n";
        }
        $moduleName = $this->method->getModuleName();

        $phpFunction .= "function {$this->method->getFunctionName()}({$this->displayParamsWithType($this->method->getParams())}){$returnType}
{
    error_clear_last();
";

        if (!$this->method->isOverloaded()) {
            $phpFunction .= '    $result = '.$this->printFunctionCall($this->method);
        } else {
            $method = $this->method;
            $inElse = false;
            do {
                $lastParameter = $method->getParams()[count($method->getParams())-1];
                if ($inElse) {
                    $phpFunction .= ' else';
                } else {
                    $phpFunction .= '    ';
                }
                if ($lastParameter->isVariadic()) {
                    $defaultValueToString = '[]';
                } else {
                    $defaultValue = $lastParameter->getDefaultValue();
                    $defaultValueToString = $this->defaultValueToString($defaultValue);
                }
                $phpFunction .= 'if ($'.$lastParameter->getParameter().' !== '.$defaultValueToString.') {'."\n";
                $phpFunction .= '        $result = '.$this->printFunctionCall($method)."\n";
                $phpFunction .= '    }';
                $inElse = true;
                $method = $method->cloneAndRemoveAParameter();
                if (!$method->isOverloaded()) {
                    break;
                }
            } while (true);
            $phpFunction .= 'else {'."\n";
            $phpFunction .= '        $result = '.$this->printFunctionCall($method)."\n";
            $phpFunction .= '    }';
        }

        $phpFunction .= $this->generateExceptionCode($moduleName, $this->method).$returnStatement. '}

';

        return $phpFunction;
    }
576071
public static function getCont($nlevel, $nrec): string
    {
        $text = '';

        $subrecords = explode("\n", $nrec);
        foreach ($subrecords as $thisSubrecord) {
            if (substr($thisSubrecord, 0, 2) !== $nlevel . ' ') {
                continue;
            }
            $subrecordType = substr($thisSubrecord, 2, 4);
            if ($subrecordType === 'CONT') {
                $text .= "\n" . substr($thisSubrecord, 7);
            }
        }

        return $text;
    }
1185976
public function getCorrectlyCasedMethodId($context_self = null)
    {
        if ($this->function instanceof ClassMethod) {
            $function_name = (string)$this->function->name;

            return ($context_self ?: $this->source->getFQCLN()) . '::' . $function_name;
        }

        if ($this->function instanceof Function_) {
            $namespace = $this->source->getNamespace();

            return ($namespace ? $namespace . '\\' : '') . $this->function->name;
        }

        return $this->getMethodId();
    }
763105
public static function numberToPrice(int $number = 0, int $after = 2, bool $use_thousand_separator = false): string
    {
        $number = str_replace(',', '.', $number);

        if (!preg_match('/^[.0-9]+$/', $number)) {
            return $number;
        }

        if ($use_thousand_separator) {
            return number_format($number, $after);
        }

        return number_format($number, $after, '.', '');
    }
1240468
def get_numeric_value(string_value):
    
    num_chars = ['.', '+', '-']
    number = ''
    for c in string_value:
        if c.isdigit() or c in num_chars:
            number += c
    return number
956515
protected function getCustomNumericFunctions()
    {
        $functions = (array) $this->getOption('custom_numeric_functions');

        return array_filter(
            $functions,
            function ($name) {
                return is_string($name);
            },
            ARRAY_FILTER_USE_KEY
        );
    }
87822
public static boolean isFormula(String formula) {
        while (FORMULA_REPLACE_PATTERN.matcher(formula).find()) {
            formula = formula.replaceAll(CALCULATION_FORMULA_PATTERN_STRING, "0");
        }
        return CALCULATION_FORMULA_PATTERN.matcher(formula).matches();
    }