src/i18n/Formatter.php
protected function normalizeNumericStringValue($value)
    {
        $separatorPosition = strrpos($value, '.');
        
        if ($separatorPosition !== false) {
            $integerPart = substr($value, 0, $separatorPosition);
            $fractionalPart = substr($value, $separatorPosition + 1);
        } else {
            $integerPart = $value;
            $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');
        }
        
        $normalizedValue = $integerPart;
        if (!empty($fractionalPart)) {
            $normalizedValue .= '.' . $fractionalPart;
        } elseif ($normalizedValue === '-0') {
            $normalizedValue = '0';
        }
        
        return $normalizedValue;
    }
protected function normalizeNumericStringValue($value)
    {
        $separatorPosition = strrpos($value, '.');
        
        if ($separatorPosition !== false) {
            $integerPart = substr($value, 0, $separatorPosition);
            $fractionalPart = substr($value, $separatorPosition + 1);
        } else {
            $integerPart = $value;
            $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');
        }
        
        $normalizedValue = $integerPart;
        if (!empty($fractionalPart)) {
            $normalizedValue .= '.' . $fractionalPart;
        } elseif ($normalizedValue === '-0') {
            $normalizedValue = '0';
        }
        
        return $normalizedValue;
    }
protected function normalizeNumericStringValue ( $ value ) { $ separatorPosition = strrpos ( $ value , '.' ) ; if ( $ separatorPosition !== false ) { $ integerPart = substr ( $ value , 0 , $ separatorPosition ) ; $ fractionalPart = substr ( $ value , $ separatorPosition + 1 ) ; } else { $ integerPart = $ value ; $ 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' ) ; } $ normalizedValue = $ integerPart ; if ( ! empty ( $ fractionalPart ) ) { $ normalizedValue .= '.' . $ fractionalPart ; } elseif ( $ normalizedValue === '-0' ) { $ normalizedValue = '0' ; } 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 .