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

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

            return $result;
        }

        if ($decimals !== null) {
            return sprintf("%.{$decimals}E", $value);
        }

        return sprintf('%.E', $value);
    }
public function asScientific($value, $decimals = null, $options = [], $textOptions = [])
    {
        if ($value === null) {
            return $this->getNullDisplay();
        }
        $value = $this->normalizeNumericValue($value);

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

            return $result;
        }

        if ($decimals !== null) {
            return sprintf("%.{$decimals}E", $value);
        }

        return sprintf('%.E', $value);
    }
public function asScientific ( $ value , $ decimals = null , $ options = [ ] , $ textOptions = [ ] ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } $ value = $ this -> normalizeNumericValue ( $ value ) ; if ( $ this -> _intlLoaded ) { $ f = $ this -> createNumberFormatter ( NumberFormatter :: SCIENTIFIC , $ decimals , $ options , $ textOptions ) ; if ( ( $ result = $ f -> format ( $ value ) ) === false ) { throw new InvalidArgumentException ( 'Formatting scientific number value failed: ' . $ f -> getErrorCode ( ) . ' ' . $ f -> getErrorMessage ( ) ) ; } return $ result ; } if ( $ decimals !== null ) { return sprintf ( "%.{$decimals}E" , $ value ) ; } return sprintf ( '%.E' , $ value ) ; }
Formats the value as a scientific number.

@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 depends on your PHP configuration.
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.
Formats the value as a scientific number .