src/CFPropertyList/CFBinaryPropertyList.php
protected function readBinaryReal($length)
    {
        if ($length > 3) {
            throw new PListException("Real greater than 8 bytes: $length");
        }

        $nbytes = 1 << $length;
        $val = null;
        if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
            throw IOException::readError("");
        }
        $this->pos += $nbytes;

        switch ($length) {
            case 0: // 1 byte float? must be an error
            case 1: // 2 byte float? must be an error
                $x = $length + 1;
                throw new PListException("got {$x} byte float, must be an error!");
            case 2:
                $val = unpack("f", strrev($buff));
                $val = $val[1];
                break;
            case 3:
                $val = unpack("d", strrev($buff));
                $val = $val[1];
                break;
        }

        return new CFNumber($val);
    }
protected function readBinaryReal($length)
    {
        if ($length > 3) {
            throw new PListException("Real greater than 8 bytes: $length");
        }

        $nbytes = 1 << $length;
        $val = null;
        if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
            throw IOException::readError("");
        }
        $this->pos += $nbytes;

        switch ($length) {
            case 0: // 1 byte float? must be an error
            case 1: // 2 byte float? must be an error
                $x = $length + 1;
                throw new PListException("got {$x} byte float, must be an error!");
            case 2:
                $val = unpack("f", strrev($buff));
                $val = $val[1];
                break;
            case 3:
                $val = unpack("d", strrev($buff));
                $val = $val[1];
                break;
        }

        return new CFNumber($val);
    }
protected function readBinaryReal ( $ length ) { if ( $ length > 3 ) { throw new PListException ( "Real greater than 8 bytes: $length" ) ; } $ nbytes = 1 << $ length ; $ val = null ; if ( strlen ( $ buff = substr ( $ this -> content , $ this -> pos , $ nbytes ) ) != $ nbytes ) { throw IOException :: readError ( "" ) ; } $ this -> pos += $ nbytes ; switch ( $ length ) { case 0 : // 1 byte float? must be an error case 1 : // 2 byte float? must be an error $ x = $ length + 1 ; throw new PListException ( "got {$x} byte float, must be an error!" ) ; case 2 : $ val = unpack ( "f" , strrev ( $ buff ) ) ; $ val = $ val [ 1 ] ; break ; case 3 : $ val = unpack ( "d" , strrev ( $ buff ) ) ; $ val = $ val [ 1 ] ; break ; } return new CFNumber ( $ val ) ; }
Read a real value
@param integer $length The length (in bytes) of the integer value, coded as „set bit $length to 1”
@return CFNumber The real value
@throws PListException if real val is invalid
@throws IOException if read error occurs
Read a real value