Similar to format_float, formats the numbers and list separators
according to locale specifics.
@param string $formula
@return string localised formula
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;
    }
835321
def format(target)
      begin
        number = number_with_precision(target, @precision)
        parts = number.split('.')
        if parts.at(1).nil?
          parts[0] + "%"
        else
          parts[0] + @separator + parts[1].to_s + "%"
        end
      rescue
        target
      end
    end
487109
public function numberFormat()
    {
        $num = (float) ((string) $this->getRequiredParameter('number'));
        $decimals = intval((string)$this->getParameter('decimals'));
        return number_format($num, $decimals);
    }
702188
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false)
    {
        $value     = PHPExcel_Calculation_Functions::flattenSingleValue($value);
        $decimals  = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
        $no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);

        // Validate parameters
        if (!is_numeric($value) || !is_numeric($decimals)) {
            return PHPExcel_Calculation_Functions::NaN();
        }
        $decimals = floor($decimals);

        $valueResult = round($value, $decimals);
        if ($decimals < 0) {
            $decimals = 0;
        }
        if (!$no_commas) {
            $valueResult = number_format($valueResult, $decimals);
        }

        return (string) $valueResult;
    }
1090627
function formatSingle(format, val) {
        var floatRegex = /f$/,
          decRegex = /\.([0-9])/,
          lang = defaultOptions.lang,
          decimals;

        if (floatRegex.test(format)) { // float
            decimals = format.match(decRegex);
            decimals = decimals ? decimals[1] : -1;
            if (val !== null) {
                val = numberFormat(
                  val,
                  decimals,
                  lang.decimalPoint,
                  format.indexOf(',') > -1 ? lang.thousandsSep : ''
                );
            }
        } else {
            val = dateFormat(format, val);
        }
        return val;
    }
812537
private static function floatToString(float $float) : string
    {
        $currentLocale = \setlocale(LC_NUMERIC, '0');
        \setlocale(LC_NUMERIC, 'C');

        $result = (string) $float;

        \setlocale(LC_NUMERIC, $currentLocale);

        return $result;
    }
22010
public function write_formula($row, $col, $formula, $format = null) {
        $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
        $this->apply_format($row, $col, $format);
    }
629457
public function calc_formula($formula, $params=false) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($formula, $params);
    }
645221
private function toDms(float $decimal, string $axis = self::LATITUDE): string
    {
        $d = (int) floor(abs($decimal));
        $m = (int) floor((abs($decimal) - $d) * 60);
        $s = ((abs($decimal) - $d) * 60 - $m) * 60;
        if (self::LATITUDE === $axis) {
            $h = ($decimal < 0) ? 'S' : 'N';
        } else {
            $h = ($decimal < 0) ? 'W' : 'E';
        }

        return sprintf('%d %d %.3f %s', $d, $m, $s, $h);
    }
531505
function parse($formula)
    {
        $this->_current_char = 0;
        $this->_formula      = $formula;
        $this->_lookahead    = $formula{1};
        $this->_advance();
        $this->_parse_tree   = $this->_condition();
        if (PEAR::isError($this->_parse_tree)) {
            return $this->_parse_tree;
        }
        return true;
    }
839676
private static String breakExtractor(String formula) {
        boolean finalBreak = false;

        int innerMostBracket = formula.lastIndexOf("(");
        
        if (innerMostBracket<0)
        	return formula;
        
        String finalformula = formula.substring(0, innerMostBracket);
        String multipliedformula = "";
        String formulaEnd = "";
        String multiple = "";
        
        for (int f = innerMostBracket + 1; f < formula.length(); f++) {
            char thisChar = formula.charAt(f);
            
        	if ( finalBreak ) {
        		if ( isDigit(thisChar) ){
                    multiple += thisChar;
                } else {
                	formulaEnd = formula.substring(f, formula.length());
                	break;
                }
        	}else {
        		if ( thisChar == ')' ) {
                    finalBreak = true;
                }else
                    multipliedformula += thisChar;
        	}
        }
        finalformula += muliplier(multipliedformula, multiple.isEmpty() ? 1:Integer.valueOf(multiple)) + formulaEnd;
        
        if (finalformula.contains("("))
        	return breakExtractor(finalformula);
        else
        	return finalformula;
    }
445611
public static function denormalize_formula($formula, $courseid) {
        if (empty($formula)) {
            return '';
        }

        // denormalize formula - convert ##giXX## to [[idnumber]]
        if (preg_match_all('/##gi(\d+)##/', $formula, $matches)) {
            foreach ($matches[1] as $id) {
                if ($grade_item = grade_item::fetch(array('id'=>$id, 'courseid'=>$courseid))) {
                    if (!empty($grade_item->idnumber)) {
                        $formula = str_replace('##gi'.$grade_item->id.'##', '[['.$grade_item->idnumber.']]', $formula);
                    }
                }
            }
        }

        return $formula;

    }
1218792
public static function format($number, $decimals = null, $decimalPoint = null,
                                  $thousandsSeparator = null)
    {
        if (is_null($decimals)) {
            $decimals = self::$decimals;
        }
        if (is_null($decimalPoint)) {
            $decimalPoint = self::$decimalPoint;
        }
        if (is_null($thousandsSeparator)) {
            $thousandsSeparator = self::$thousandsSeparator;
        }
        return number_format($number, $decimals, $decimalPoint, $thousandsSeparator);
    }
174743
public function formatToWholeNumbers(
        $float,
        $locale = null
    ) {
        if (is_null($locale)) {
            $locale = $this->defaultLocale;
        }

        $formatter = $this->retrieveDecimalFormatter($locale);

        return $formatter->format($float);
    }
729915
private function getFormatter($locale = 'de-AT')
    {
        $formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);
        $formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 2);
        $formatter->setAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);

        return $formatter;
    }
542652
private function group(&$formula, $opt = 'init') {
        if ($opt == 'init') {
            // Numbers in E notation
            $formula = preg_replace_callback('/[\d\.]+( )?[eE]( )?[\+\-]?( )?[\d\.]+ /',
                    [$this, 'match'], $formula);
            // Variables
            if (count($this->variables) > 0) {
            	$valid_variables = implode("|", $this->valid_variables);
                $formula = preg_replace_callback('/[\+\-\*\/\^ ]('.$valid_variables.')[ \+\-\*\/\^]/',
                        [$this, 'match1'], $formula);
            }
        } else {
            // Functions
            $valid_functions = implode("|", $this->valid_functions);
            $formula = preg_replace_callback('/('.$valid_functions.')( )?[\+\-]?( )?[\d\.eEINF]+ /',
                    [$this, 'match2'], $formula);
        }
    }
214196
protected function formatValue($value)
    {
        if (is_string($value)
            && !is_numeric($value)
        ) {
            $value = html_entity_decode($value, ENT_COMPAT, 'UTF-8');
        } elseif ($value === false) {
            $value = 0;
        }

        $value = $this->formatFormulas($value);

        if (is_string($value)
            && (strpos($value, '"') !== false
                || strpos($value, $this->separator) !== false)
        ) {
            $value = '"' . str_replace('"', '""', $value) . '"';
        }

        // in some number formats (e.g. German), the decimal separator is a comma
        // we need to catch and replace this
        if (is_numeric($value)) {
            $value = (string)$value;
            $value = str_replace(',', '.', $value);
        }

        return $value;
    }