@param string $data

@throws UnexpectedValueException

@return float
761644
private function extractScriptDataValue_Double(&$data)
    {
        $result = $this->parseDouble(substr($data, 0, 8));
        $data = substr($data, 8);

        return $result;
    }
1055913
private static function _nr3ToDecimal(string $str): float
    {
        /** @var $match string[] */
        if (!preg_match(self::NR3_REGEX, $str, $match)) {
            throw new \UnexpectedValueException(
                "'$str' is not a valid NR3 form real.");
        }
        $m = $match[2];
        // if number started with minus sign
        $inv = $match[1] == "-";
        $e = intval($match[3]);
        // positive exponent
        if ($e > 0) {
            // pad with trailing zeroes
            $num = $m . str_repeat("0", $e);
        } else if ($e < 0) {
            // pad with leading zeroes
            if (strlen($m) < abs($e)) {
                $m = str_repeat("0", abs($e) - strlen($m)) . $m;
            }
            // insert decimal point
            $num = substr($m, 0, $e) . "." . substr($m, $e);
        } else {
            $num = empty($m) ? "0" : $m;
        }
        // if number is negative
        if ($inv) {
            $num = "-$num";
        }
        return floatval($num);
    }
1239061
private function serializeDataToXml($data)
    {
        if ($data instanceof \SimpleXMLElement) {
            return $data->asXML();
        }
        
        if (($data instanceof \DOMNode && isset($data->ownerDocument)) || $data instanceof \DOMDocument) {
            $dom = $data instanceof \DOMDocument ? $data : $data->ownerDocument;
            return $dom->saveXML($data);
        }
        
        $type = (is_object($data) ? get_class($data) . ' ' : '') . gettype($data);
        throw new \UnexpectedValueException("Unable to serialize $type to XML");
    }
359162
protected function serializeData($data, $contentType)
    {
        if (is_string($data)) {
            return $data;
        }
        
        $repository = new ApacheMimeTypes();
        list($format) = $repository->findExtensions($contentType) + [null];
        
        $method = 'serializeDataTo' . $format;
        
        if (method_exists($this, $method)) {
            return $this->$method($data);
        }

        $type = (is_object($data) ? get_class($data) . ' ' : '') . gettype($data);
        throw new \UnexpectedValueException("Unable to serialize $type to '$contentType'");
    }
241272
public static function valueTrim(array $data)
    {
        if (is_scalar($data)) {
            return trim($data);
        }

        array_walk_recursive($data, function (&$value) {
            $value = trim($value);
        });

        return $data;
    }
1321396
public function getFloatValue($key)
    {
        $value = $this->get($key);
        if ($value === null) {
            return null;
        }
        return (float)$value;
    }
1218737
public function getValueFromData($data, $default = null)
    {
        $columnName = $this->valueFrom ?: $this->columnName;
        return $this->getColumnNameFromData($columnName, $data, $default);
    }
727918
public function setValues($data)
    {
        if (!is_array($data)) {
            return $this;
        }

        foreach ($data as $key => $value) {
            $this->$key = $value;
        }
    }
491045
public function getValue() {
        $value = parent::getValue();
        if ($value) {
            $value = unformat_float($value, true);
        }
        return $value;
    }
98771
public static function create($data, $class)
    {
        if ('[]' === substr($class, -2)) {
            return self::createCollection($data, substr($class, 0, -2));
        }

        if (null === $data) {
            return null;
        }

        if (!\is_array($data)) {
            throw new \UnexpectedValueException(
                sprintf('Expected null or array, %s given.', \gettype($data))
            );
        }

        return self::createObject($data, $class);
    }
681841
private static function arrarval($data)
    {
        if (is_object($data) && get_class($data) === 'SimpleXMLElement') {
            $data = (array) $data;
        }

        if (is_array($data)) {
            foreach ($data as $index => $value) {
                $data[$index] = self::arrarval($value);
            }
        }

        return $data;
    }
931778
private static function toFloat($x)
    {
        if (is_float($x)) return $x;
        if (is_int($x)) return $x;
        if (is_string($x)) {
            $r = Rational::parse($x);
            return $r->p/$r->q;
        }
        throw new SyntaxErrorException();
    }
260314
public function unserialize($data) {
        $value = $this->fromData($data);
        foreach ($this->getFilters() as $filter) {
            $value = $filter->toValue($value);
        }
        return $value;
    }
953767
public static function toBytes(String $data) : Float
    {
        $number = substr($data, 0, -2);

        switch( strtoupper(substr($data, -2)) )
        {
            case 'KB': return $number * 1024;
            case 'MB': return $number * pow(1024, 2);
            case 'GB': return $number * pow(1024, 3);
            case 'TB': return $number * pow(1024, 4);
            case 'PB': return $number * pow(1024, 5);

            default  : return $data;
        }
    }
732288
public function get($key)
    {
        if (!$this->offsetExists($key)) {
            throw new UnexpectedValueException(sprintf('Unknown key %s.', $key));
        }

        return $this->offsetGet($key);
    }
507812
private function escapeFloatsIfNeeded(array $data)
    {
        if (PHP_VERSION_ID >= 50606) {
            return $data;
        }

        array_walk_recursive(
            $data,
            function (&$value) {
                if (is_float($value) && ctype_digit((string)$value)) {
                    // Due to PHP bug #50224, floats with no decimals are converted to integers when encoded
                    $value = '(' . self::FLOAT_CASTER . ')' . $value . '.0';
                }
            }
        );

        return $data;
    }
36831
public static function encode( array $data ) {
		$format = ini_get( 'session.serialize_handler' );
		if ( !is_string( $format ) ) {
			throw new \UnexpectedValueException(
				'Could not fetch the value of session.serialize_handler'
			);
		}
		switch ( $format ) {
			case 'php':
				return self::encodePhp( $data );

			case 'php_binary':
				return self::encodePhpBinary( $data );

			case 'php_serialize':
				return self::encodePhpSerialize( $data );

			default:
				throw new \DomainException( "Unsupported format \"$format\"" );
		}
	}