private function formatSiNumber($value, $decimals, $maxPosition, $options, $textOptions)
    {
        if (is_string($value) && is_numeric($value)) {
            $value = (int) $value;
        }
        if (!is_numeric($value)) {
            throw new InvalidParamException("'$value' is not a numeric value.");
        }
        $formatBase = 1000;

        $position = 0;
        do {
            if ($value < $formatBase) {
                break;
            }
            $value = $value / $formatBase;
            $position++;
        } while ($position < $maxPosition);

        // no decimals for base unit
        if ($position === 0) {
            $decimals = 0;
        } elseif ($decimals !== null) {
            $value = round($value, $decimals);
        }
        // disable grouping for edge cases like 1023 to get 1023 B instead of 1,023 B
        $oldThousandSeparator = $this->thousandSeparator;
        $this->thousandSeparator = '';
        if ($this->_intlLoaded) {
            $options[\NumberFormatter::GROUPING_USED] = false;
        }
        // format the size value
        $params = [
            // this is the unformatted number used for the plural rule
            'n' => $value,
            // this is the formatted number used for display
            'nFormatted' => $this->asDecimal($value, $decimals, $options, $textOptions),
        ];
        $this->thousandSeparator = $oldThousandSeparator;

        return [$params, $position];
    }
private function formatSiNumber($value, $decimals, $maxPosition, $options, $textOptions)
    {
        if (is_string($value) && is_numeric($value)) {
            $value = (int) $value;
        }
        if (!is_numeric($value)) {
            throw new InvalidParamException("'$value' is not a numeric value.");
        }
        $formatBase = 1000;

        $position = 0;
        do {
            if ($value < $formatBase) {
                break;
            }
            $value = $value / $formatBase;
            $position++;
        } while ($position < $maxPosition);

        // no decimals for base unit
        if ($position === 0) {
            $decimals = 0;
        } elseif ($decimals !== null) {
            $value = round($value, $decimals);
        }
        // disable grouping for edge cases like 1023 to get 1023 B instead of 1,023 B
        $oldThousandSeparator = $this->thousandSeparator;
        $this->thousandSeparator = '';
        if ($this->_intlLoaded) {
            $options[\NumberFormatter::GROUPING_USED] = false;
        }
        // format the size value
        $params = [
            // this is the unformatted number used for the plural rule
            'n' => $value,
            // this is the formatted number used for display
            'nFormatted' => $this->asDecimal($value, $decimals, $options, $textOptions),
        ];
        $this->thousandSeparator = $oldThousandSeparator;

        return [$params, $position];
    }
private function formatSiNumber ( $ value , $ decimals , $ maxPosition , $ options , $ textOptions ) { if ( is_string ( $ value ) && is_numeric ( $ value ) ) { $ value = ( int ) $ value ; } if ( ! is_numeric ( $ value ) ) { throw new InvalidParamException ( "'$value' is not a numeric value." ) ; } $ formatBase = 1000 ; $ position = 0 ; do { if ( $ value < $ formatBase ) { break ; } $ value = $ value / $ formatBase ; $ position ++ ; } while ( $ position < $ maxPosition ) ; // no decimals for base unit if ( $ position === 0 ) { $ decimals = 0 ; } elseif ( $ decimals !== null ) { $ value = round ( $ value , $ decimals ) ; } // disable grouping for edge cases like 1023 to get 1023 B instead of 1,023 B $ oldThousandSeparator = $ this -> thousandSeparator ; $ this -> thousandSeparator = '' ; if ( $ this -> _intlLoaded ) { $ options [ \ NumberFormatter :: GROUPING_USED ] = false ; } // format the size value $ params = [ // this is the unformatted number used for the plural rule 'n' => $ value , // this is the formatted number used for display 'nFormatted' => $ this -> asDecimal ( $ value , $ decimals , $ options , $ textOptions ) , ] ; $ this -> thousandSeparator = $ oldThousandSeparator ; return [ $ params , $ position ] ; }
Given the value in a base unit formats number part of the human readable form.

@param string|integer|float $value value in base unit to be formatted.
@param integer $decimals the number of digits after the decimal point
@param integer $maxPosition maximum internal position of size unit
@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 array [parameters for Yii::t containing formatted number, internal position of size unit]
@throws InvalidParamException if the input value is not numeric or the formatting failed.
Given the value in a base unit formats number part of the human readable form .