Formats the number as a decimal number.
@param float $float The number to format
@param int $digits The maximum number of decimal digits
@return string The number formatted as a decimal number
198359
private function formatFloat($float, $digits)
    {
        $digits = max((int) $digits, 1);
        $string = rtrim(number_format($float, $digits, '.', ''), '0');

        return substr($string, -1) === '.' ? $string . '0' : $string;
    }
236917
public function format($decimals = 0, $decPoint = '.', $thousandsSep = ' ')
    {
        $decimals = max(0, (int) $decimals);
        $dec      = '';
        // do not mutate
        $number   = (new static($this))->round($decimals)->normalize();
        $sign     = $number->isPositive() ? '' : '-';
        if ($number->abs()->hasDecimals()) {
            list($number, $dec) = explode('.', (string) $number);
        }

        if ($decimals) {
            $dec = sprintf("%'0-" . $decimals . 's', $dec);
        }

        return $sign . preg_replace("/(?<=\d)(?=(\d{3})+(?!\d))/", $thousandsSep, $number) . ($decimals ? $decPoint . $dec : '');
    }
927103
function formatNumber( $number )
    {
        $neg = $number < 0;
        $num = $neg ? -$number : $number;
        $text = number_format( $num, $this->FractDigits, $this->DecimalSymbol, $this->ThousandsSeparator );
        return ( $neg ? $this->NegativeSymbol : $this->PositiveSymbol ) . $text;
    }
554512
public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
    {
        return $this->numberFormat($this->tax, $decimals, $decimalPoint, $thousandSeperator);
    }
618623
public static function nFloat($number, $decimals = 2, $showThousands = false)
    {
        if (is_null($number) || empty(self::onlyNumbers($number)) || floatval($number) == 0) {
            return 0;
        }
        $pontuacao = preg_replace('/[0-9]/', '', $number);
        $locale = (mb_substr($pontuacao, -1, 1) == ',') ? "pt-BR" : "en-US";
        $formater = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);

        if ($decimals === false) {
            $decimals = 2;
            preg_match_all('/[0-9][^0-9]([0-9]+)/', $number, $matches);
            if (!empty($matches[1])) {
                $decimals = mb_strlen(rtrim($matches[1][0], 0));
            }
        }

        return number_format($formater->parse($number, \NumberFormatter::TYPE_DOUBLE), $decimals, '.', ($showThousands ? ',' : ''));
    }
979379
public static function format($value, int $decimals = 2): ?string {
        if (!\is_numeric($value)) {
            return null;
        }
        return \number_format($value, $decimals);
    }
4510
public function format_float($field)
    {
        $precision = 2;
        $m = (float) $this->current_row[$field];
        $this->current_row[$field] =
            is_null($this->current_row[$field])
                ? '-'
                : number_format($m, $precision);
        $this->setTDParam($field, 'align', 'right');
        $this->setTDParam($field, 'style/white-space', 'nowrap');
    }
397203
public function numberFormat($number, int $decimals = 0): string
    {
        if (!isset($this->numberFormatter)) {
            $this->numberFormatter = new NumberFormatter($this->intuition->getLang(), NumberFormatter::DECIMAL);
        }
        $this->numberFormatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
        return $this->numberFormatter->format($number);
    }
14541
public static function decimalFormat($value)
    {
        if (is_int($value)) {
            return $value;
        }else if (is_float($value)) {
            if (strcspn(strrev($value), '.') >= 3) {
                $value = floor($value * 100) / 100;
            }
        }
        return (string)number_format($value, 2, '.', '');
    }
209529
public function formatNumber($amount, array $currency)
    {
        $rounded = $this->round(abs($amount), $currency);
        return number_format($rounded, $currency['decimals'], $currency['decimal_separator'], $currency['thousands_separator']);
    }
1154585
protected function getFormatter($locale, $digits)
    {
        $formatter = $this->retrieveDecimalFormatter($locale);
        $formatter->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $digits);
        $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $digits);
        $formatter->setAttribute(NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);

        return $formatter;
    }
1213908
public static function formatCurrency(float $value, string $currency, int $format = null) : string
    {
        $formatter = new NumberFormatter(self::translator()->getIETF(), NumberFormatter::CURRENCY);

        if ($format && $format & self::FORMAT_SHORT) {
            $diff = pow(10, -$formatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
            $decimal = (float) (floatval((string) $value) - (int) floatval((string) $value));

            if ($decimal < $diff) {
                $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 0);
            }
        }

        return $formatter->formatCurrency($value, $currency);
    }
1319061
public function formatStandardNumber($number, $decimals = null)
    {
        $lang = $this->request->getSession()->getLang();

        if ($decimals === null) {
            $decimals = $lang->getDecimals();
        }

        return number_format($number, $decimals, '.', '');
    }
647020
public function format(
        $price,
        $digits = null,
        $locale = null,
        $currency = null,
        $currencyPosition = self::CURRENCY_LOCATION_NONE
    ) {
        if (is_null($locale)) {
            $locale = $this->defaultLocale;
        }

        if (is_null($digits)) {
            $digits = $this->defaultDigits;
        }

        $formatter = $this->getFormatter($locale, $digits);
        $formattedPrice = $formatter->format($price);

        if ($currencyPosition != self::CURRENCY_LOCATION_NONE && is_null($currency)) {
            throw new PriceFormatterException('currency must be set, if location is set');
        }

        switch ($currencyPosition) {
            case self::CURRENCY_LOCATION_PREFIX:
                $formattedPrice = $currency . ' ' . $formattedPrice;
                break;
            case self::CURRENCY_LOCATION_SUFFIX:
                $formattedPrice = $formattedPrice . ' ' . $currency;
                break;
        }

        return $formattedPrice;
    }
705080
public function getPrettyNumber($value, $precision = 0)
    {
        if ($this->decimalPoint === null) {
            $locale = localeconv();

            $this->decimalPoint = $locale['decimal_point'];
            $this->thousandsSeparator = $locale['thousands_sep'];
        }

        return number_format($value, $precision, $this->decimalPoint, $this->thousandsSeparator);
    }
703569
public function unit($number, $unit, $decimals = null)
    {
        $format = $this->getFormat(self::UNIT);
        $numeric = $this->number($number, $decimals);
        return str_replace(['{number}', '{unit}'], [$numeric, $unit], $format);
    }
782530
public static function number($number, $decimals = 0)
    {
        $l = self::getLocale();
        return number_format($number, $decimals, $l->decimalPoint, $l->thousandsSep);
    }