framework/i18n/Formatter.php
protected function normalizeNumericStringValue($value)
    {
        $powerPosition = strrpos($value, 'E');
        if ($powerPosition !== false) {
            $valuePart = substr($value, 0, $powerPosition);
            $powerPart = substr($value, $powerPosition + 1);
        } else {
            $powerPart = null;
            $valuePart = $value;
        }

        $separatorPosition = strrpos($valuePart, '.');

        if ($separatorPosition !== false) {
            $integerPart = substr($valuePart, 0, $separatorPosition);
            $fractionalPart = substr($valuePart, $separatorPosition + 1);
        } else {
            $integerPart = $valuePart;
            $fractionalPart = null;
        }

        // truncate insignificant zeros, keep minus
        $integerPart = preg_replace('/^\+?(-?)0*(\d+)$/', '$1$2', $integerPart);
        // for zeros only leave one zero, keep minus
        $integerPart = preg_replace('/^\+?(-?)0*$/', '${1}0', $integerPart);

        if ($fractionalPart !== null) {
            // truncate insignificant zeros
            $fractionalPart = rtrim($fractionalPart, '0');

            if (empty($fractionalPart)) {
                $fractionalPart = $powerPart !== null ? '0' : null;
            }
        }

        $normalizedValue = $integerPart;
        if ($fractionalPart !== null) {
            $normalizedValue .= '.' . $fractionalPart;
        } elseif ($normalizedValue === '-0') {
            $normalizedValue = '0';
        }

        if ($powerPart !== null) {
            $normalizedValue .= 'E' . $powerPart;
        }

        return $normalizedValue;
    }
protected function normalizeNumericStringValue($value)
    {
        $powerPosition = strrpos($value, 'E');
        if ($powerPosition !== false) {
            $valuePart = substr($value, 0, $powerPosition);
            $powerPart = substr($value, $powerPosition + 1);
        } else {
            $powerPart = null;
            $valuePart = $value;
        }

        $separatorPosition = strrpos($valuePart, '.');

        if ($separatorPosition !== false) {
            $integerPart = substr($valuePart, 0, $separatorPosition);
            $fractionalPart = substr($valuePart, $separatorPosition + 1);
        } else {
            $integerPart = $valuePart;
            $fractionalPart = null;
        }

        // truncate insignificant zeros, keep minus
        $integerPart = preg_replace('/^\+?(-?)0*(\d+)$/', '$1$2', $integerPart);
        // for zeros only leave one zero, keep minus
        $integerPart = preg_replace('/^\+?(-?)0*$/', '${1}0', $integerPart);

        if ($fractionalPart !== null) {
            // truncate insignificant zeros
            $fractionalPart = rtrim($fractionalPart, '0');

            if (empty($fractionalPart)) {
                $fractionalPart = $powerPart !== null ? '0' : null;
            }
        }

        $normalizedValue = $integerPart;
        if ($fractionalPart !== null) {
            $normalizedValue .= '.' . $fractionalPart;
        } elseif ($normalizedValue === '-0') {
            $normalizedValue = '0';
        }

        if ($powerPart !== null) {
            $normalizedValue .= 'E' . $powerPart;
        }

        return $normalizedValue;
    }
protected function normalizeNumericStringValue ( $ value ) { $ powerPosition = strrpos ( $ value , 'E' ) ; if ( $ powerPosition !== false ) { $ valuePart = substr ( $ value , 0 , $ powerPosition ) ; $ powerPart = substr ( $ value , $ powerPosition + 1 ) ; } else { $ powerPart = null ; $ valuePart = $ value ; } $ separatorPosition = strrpos ( $ valuePart , '.' ) ; if ( $ separatorPosition !== false ) { $ integerPart = substr ( $ valuePart , 0 , $ separatorPosition ) ; $ fractionalPart = substr ( $ valuePart , $ separatorPosition + 1 ) ; } else { $ integerPart = $ valuePart ; $ fractionalPart = null ; } // truncate insignificant zeros, keep minus $ integerPart = preg_replace ( '/^\+?(-?)0*(\d+)$/' , '$1$2' , $ integerPart ) ; // for zeros only leave one zero, keep minus $ integerPart = preg_replace ( '/^\+?(-?)0*$/' , '${1}0' , $ integerPart ) ; if ( $ fractionalPart !== null ) { // truncate insignificant zeros $ fractionalPart = rtrim ( $ fractionalPart , '0' ) ; if ( empty ( $ fractionalPart ) ) { $ fractionalPart = $ powerPart !== null ? '0' : null ; } } $ normalizedValue = $ integerPart ; if ( $ fractionalPart !== null ) { $ normalizedValue .= '.' . $ fractionalPart ; } elseif ( $ normalizedValue === '-0' ) { $ normalizedValue = '0' ; } if ( $ powerPart !== null ) { $ normalizedValue .= 'E' . $ powerPart ; } return $ normalizedValue ; }
Normalizes a numeric string value.
@param string $value
@return string the normalized number value as a string
@since 2.0.16
Normalizes a numeric string value .