Overrides parent::format().

@param float|string $number
@param string $currency_sign
An ISO 4217 code or currency sign.
766598
public function format($number, $currency_sign = NULL) {
    $this->symbol_replacements[self::SYMBOL_SPECIAL_CURRENCY] = $currency_sign;

    return parent::format($number);
  }
986966
public static void format(
      BigDecimal n,
      DigitBuffer buf,
      NumberFormatterParams params,
      boolean currencyMode,
      boolean grouping,
      int minIntDigits,
      int primaryGroupingSize,
      int secondaryGroupingSize) {

    // Setup integer digit grouping.
    if (secondaryGroupingSize <= 0) {
      secondaryGroupingSize = primaryGroupingSize;
    }

    // Check if we need to perform digit grouping.
    int groupSize = primaryGroupingSize;
    boolean shouldGroup = false;

    // Output as many integer digits as are available, unless minIntDigits == 0
    // and our value is < 1.
    long intDigits = integerDigits(n);
    if (minIntDigits == 0 && n.compareTo(BigDecimal.ONE) == -1) {
      intDigits = 0;
    } else {
      intDigits = Math.max(intDigits, minIntDigits);
    }

    if (grouping) {
      if (primaryGroupingSize > 0) {
        shouldGroup = intDigits >= (params.minimumGroupingDigits + primaryGroupingSize);
      }
    }

    // Select the decimal and grouping characters.
    String decimal = currencyMode ? params.currencyDecimal : params.decimal;
    String group = currencyMode ? params.currencyGroup : params.group;

    // Keep a pointer to the end of the buffer, since we render the formatted number
    // in reverse to be a bit more compact.
    int bufferStart = buf.length();

    // We only emit the absolute value of the number, since the indication of
    // negative numbers is pattern and locale-specific.
    if (n.signum() == -1) {
      n = n.negate();
    }

    // Translate the standard decimal representation into the localized form.
    // At this point the number of integer and decimal digits is set, all we're
    // doing is outputting the correct decimal symbol and grouping symbols.

    String s = n.toPlainString();
    int end = s.length() - 1;

    // Emit decimal digits and decimal point.
    int idx = s.lastIndexOf('.');
    if (idx != -1) {
      while (end > idx) {
        buf.append(s.charAt(end));
        end--;
      }

      end--;
      buf.append(decimal);
    }

    // Emit integer part with optional grouping
    int emitted = 0;
    while (intDigits > 0 && end >= 0) {
      // Emit grouping digits.
      if (shouldGroup) {
        boolean emit = emitted > 0 && emitted % groupSize == 0;
        if (emit) {
          // Append a grouping character and switch to the secondary grouping size
          buf.append(group);
          emitted -= groupSize;
          groupSize = secondaryGroupingSize;
        }
      }
      buf.append(s.charAt(end));
      end--;
      emitted++;
      intDigits--;
    }

    // Emit zeroes to pad integer part with optional grouping
    if (intDigits > 0) {
      for (int i = 0; i < intDigits; i++) {
        // Emit grouping digits.
        if (shouldGroup) {
          boolean emit = emitted > 0 && emitted % groupSize == 0;
          if (emit) {
            // Append a grouping character and switch to the secondary grouping size
            buf.append(group);
            emitted -= groupSize;
            groupSize = secondaryGroupingSize;
          }
        }
        buf.append('0');
        emitted++;
      }
    }

    buf.reverse(bufferStart);
  }
785375
public function formatCurrency($value, $currency, $precision=2)
    {
        $newValue = trim($value, " \0\x0B$currency");
        if (!is_numeric($newValue)) {
            return $value;
        }

        $pattern = $this->getPattern($value, 'Intl_NumberFormatCurrency');

        if ($newValue == round($newValue)) {
            // if no fraction digits available, don't show any
            $value = $this->formatNumberWithPattern($pattern, $newValue, 0, 0);
        } else {
            // show given count of fraction digits otherwise
            $value = $this->formatNumberWithPattern($pattern, $newValue, $precision, $precision);
        }

        return str_replace('¤', $currency, $value);
    }
1056211
public function withPrefix($values, string $currency = null, int $decimal_points = null): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->prefix($value, $decimal_points);
    }
38972
public function formatAmount($amount, $currency = null)
    {
        return str_replace('.00', '', $this->moneyHelper->formatAmount($amount, $currency));
    }
1142080
public static function php_number_format($number)
    {

        preg_match('/[.,](\d+)$/', $number, $matches);

        $num_decimals = strlen($matches[1]);

        return preg_replace('/[.,]/', '', $number) / pow(10, $num_decimals);
    }
201960
public function formatByDecimal(Currencies $currencies = null)
    {
        $formatter = new DecimalMoneyFormatter($currencies ?: static::getCurrencies());

        return $this->formatByFormatter($formatter);
    }
478240
public function decimal($values, string $currency = null, int $decimal_points = 2): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->decimal($value, $decimal_points);
    }
394221
protected function cc_format($number, $options)
    {
        if (empty($number)) {
            return '';
        }

        switch ($options) {
            case 'two_digits':
                $number = sprintf("%02d", $number);
                return substr($number, -2);
                break;
            case 'four_digits':
                return sprintf("%04d", $number);
                break;
            default:
                return $number;
                break;
        }
    }
56561
public function formatByIntlLocalizedDecimal(
        $locale = null,
        Currencies $currencies = null,
        $style = NumberFormatter::CURRENCY
    ) {
        $numberFormatter = new NumberFormatter($locale ?: static::getLocale(), $style);
        $formatter = new IntlLocalizedDecimalFormatter($numberFormatter, $currencies ?: static::getCurrencies());

        return $this->formatByFormatter($formatter);
    }
661633
public static function formatAsMoney($value, $currencySymbol = "&pound;", $roundToInteger = false) {
        if (is_numeric($value))
            return $currencySymbol . number_format($value, $roundToInteger ? 0 : 2, ".", "");
        else
            return null;
    }
1123837
private void processCurrency(Row row)
   {
      String currencyName = row.getString("curr_short_name");
      DecimalFormatSymbols symbols = new DecimalFormatSymbols();
      symbols.setDecimalSeparator(row.getString("decimal_symbol").charAt(0));
      symbols.setGroupingSeparator(row.getString("digit_group_symbol").charAt(0));
      DecimalFormat nf = new DecimalFormat();
      nf.setDecimalFormatSymbols(symbols);
      nf.applyPattern("#.#");
      m_currencyMap.put(currencyName, nf);

      if (currencyName.equalsIgnoreCase(m_defaultCurrencyName))
      {
         m_numberFormat = nf;
         m_defaultCurrencyData = row;
      }
   }
1327356
def natural_number_with_currency(number, currency, show_decimal_place=True, use_nbsp=True):
    
    humanized = '{} {}'.format(
        numberformat.format(
            number=number,
            decimal_sep=',',
            decimal_pos=2 if show_decimal_place else 0,
            grouping=3,
            thousand_sep=' ',
            force_grouping=True
        ),
        force_text(currency)
    )
    return mark_safe(humanized.replace(' ', '\u00a0')) if use_nbsp else humanized
12934
function format() {
		$args=func_get_args();
		$val=array_shift($args);
		// Get formatting rules
		$conv=localeconv();
		return preg_replace_callback(
			'/\{(?P<pos>\d+)\s*(?:,\s*(?P<type>\w+)\s*'.
			'(?:,\s*(?P<mod>(?:\w+(?:\s*\{.+?\}\s*,?)?)*)'.
			'(?:,\s*(?P<prop>.+?))?)?)?\}/',
			function($expr) use($args,$conv) {
				extract($expr);
				extract($conv);
				if (!array_key_exists($pos,$args))
					return $expr[0];
				if (isset($type))
					switch ($type) {
						case 'plural':
							preg_match_all('/(?<tag>\w+)'.
								'(?:\s*\{\s*(?<data>.+?)\s*\})/',
								$mod,$matches,PREG_SET_ORDER);
							$ord=array('zero','one','two');
							foreach ($matches as $match) {
								extract($match);
								if (isset($ord[$args[$pos]]) &&
									$tag==$ord[$args[$pos]] || $tag=='other')
									return str_replace('#',$args[$pos],$data);
							}
						case 'number':
							if (isset($mod))
								switch ($mod) {
									case 'integer':
										return number_format(
											$args[$pos],0,'',$thousands_sep);
									case 'currency':
										if (function_exists('money_format'))
											return money_format(
												'%n',$args[$pos]);
										$fmt=array(
											0=>'(nc)',1=>'(n c)',
											2=>'(nc)',10=>'+nc',
											11=>'+n c',12=>'+ nc',
											20=>'nc+',21=>'n c+',
											22=>'nc +',30=>'n+c',
											31=>'n +c',32=>'n+ c',
											40=>'nc+',41=>'n c+',
											42=>'nc +',100=>'(cn)',
											101=>'(c n)',102=>'(cn)',
											110=>'+cn',111=>'+c n',
											112=>'+ cn',120=>'cn+',
											121=>'c n+',122=>'cn +',
											130=>'+cn',131=>'+c n',
											132=>'+ cn',140=>'c+n',
											141=>'c+ n',142=>'c +n'
										);
										if ($args[$pos]<0) {
											$sgn=$negative_sign;
											$pre='n';
										}
										else {
											$sgn=$positive_sign;
											$pre='p';
										}
										return str_replace(
											array('+','n','c'),
											array($sgn,number_format(
												abs($args[$pos]),
												$frac_digits,
												$decimal_point,
												$thousands_sep),
												$currency_symbol),
											$fmt[(int)(
												(${$pre.'_cs_precedes'}%2).
												(${$pre.'_sign_posn'}%5).
												(${$pre.'_sep_by_space'}%3)
											)]
										);
									case 'percent':
										return number_format(
											$args[$pos]*100,0,$decimal_point,
											$thousands_sep).'%';
									case 'decimal':
										return number_format(
											$args[$pos],$prop,$decimal_point,
												$thousands_sep);
								}
							break;
						case 'date':
							if (empty($mod) || $mod=='short')
								$prop='%x';
							elseif ($mod=='long')
								$prop='%A, %d %B %Y';
							return strftime($prop,$args[$pos]);
						case 'time':
							if (empty($mod) || $mod=='short')
								$prop='%X';
							return strftime($prop,$args[$pos]);
						default:
							return $expr[0];
					}
				return $args[$pos];
			},
			$val
		);
	}
1370889
public function formatPrice($price, $currency, $locale = null)
    {
        return $this->priceManager->getFormattedPrice($price, $currency, $locale);
    }
1245358
protected function prefixNumberWithCountryCallingCode($countryCallingCode, $numberFormat, &$formattedNumber)
    {
        switch ($numberFormat) {
            case PhoneNumberFormat::E164:
                $formattedNumber = static::PLUS_SIGN . $countryCallingCode . $formattedNumber;
                return;
            case PhoneNumberFormat::INTERNATIONAL:
                $formattedNumber = static::PLUS_SIGN . $countryCallingCode . ' ' . $formattedNumber;
                return;
            case PhoneNumberFormat::RFC3966:
                $formattedNumber = static::RFC3966_PREFIX . static::PLUS_SIGN . $countryCallingCode . '-' . $formattedNumber;
                return;
            case PhoneNumberFormat::NATIONAL:
            default:
                return;
        }
    }
1317494
public function formatAmount(int $amount, string $currencyCode = null, string $localeCode = null): string
    {
        return $this->helper->formatAmount($amount, $currencyCode ?? $this->baseCurrency, $localeCode ?? $this->localeContext->getLocaleCode());
    }