src/I18n/Formatter.php
public function asDecimal($value, $decimals = null, $options = [], $textOptions = [])
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
        $value = $this->normalizeNumericValue($value);

        if ($this->_intlLoaded) {
            $f = $this->createNumberFormatter(NumberFormatter::DECIMAL, $decimals, $options, $textOptions);
            if (($result = $f->format($value)) === false) {
                throw new InvalidArgumentException('Formatting decimal value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
            }

            return $result;
        }

        if ($decimals === null) {
            $decimals = 2;
        }

        return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator);
    }
public function asDecimal($value, $decimals = null, $options = [], $textOptions = [])
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
        $value = $this->normalizeNumericValue($value);

        if ($this->_intlLoaded) {
            $f = $this->createNumberFormatter(NumberFormatter::DECIMAL, $decimals, $options, $textOptions);
            if (($result = $f->format($value)) === false) {
                throw new InvalidArgumentException('Formatting decimal value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
            }

            return $result;
        }

        if ($decimals === null) {
            $decimals = 2;
        }

        return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator);
    }
Formats the value as a decimal number.

Property [[decimalSeparator]] will be used to represent the decimal point. The
value is rounded automatically to the defined decimal digits.

@param mixed $value the value to be formatted.
@param int $decimals the number of digits after the decimal point.
If not given, the number of digits depends in the input value and is determined based on
`NumberFormatter::MIN_FRACTION_DIGITS` and `NumberFormatter::MAX_FRACTION_DIGITS`, which can be configured
using [[$numberFormatterOptions]].
If the [PHP intl extension](http://php.net/manual/en/book.intl.php) is not available, the default value is `2`.
If you want consistent behavior between environments where intl is available and not, you should explicitly
specify a value here.
@param array $options optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]].
@param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
@return string the formatted result.
@throws InvalidArgumentException if the input value is not numeric or the formatting failed.
@see decimalSeparator
@see thousandSeparator