Reads first 8 bytes of a string and return IEEE 754 float

@param string $data Binary string that is at least 8 bytes long
@return float
542547
private static function _extractNumber($data)
	{
		$rknumhigh = self::_GetInt4d($data, 4);
		$rknumlow = self::_GetInt4d($data, 0);
		$sign = ($rknumhigh & 0x80000000) >> 31;
		$exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
		$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
		$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
		$mantissalow2 = ($rknumlow & 0x7fffffff);
		$value = $mantissa / pow( 2 , (20 - $exp));

		if ($mantissalow1 != 0) {
			$value += 1 / pow (2 , (21 - $exp));
		}

		$value += $mantissalow2 / pow (2 , (52 - $exp));
		if ($sign) {
			$value *= -1;
		}

		return $value;
	}
39305
public function read($bytes = 2082)
    {
        return feof($this->stream) ? false : fread($this->stream, $bytes);
    }
1328416
public function readVInt()
    {
        $nextByte = ord($this->_fread(1));
        $val = $nextByte & 0x7F;

        for ($shift=7; ($nextByte & 0x80) != 0; $shift += 7) {
            $nextByte = ord($this->_fread(1));
            $val |= ($nextByte & 0x7F) << $shift;
        }
        return $val;
    }
1137460
public static function maybeUn($data)
    {
        // If it isn't a string, it isn't serialized
        if (!is_string($data)) {
            return $data;
        }

        $data = trim($data);

        // Is it the serialized NULL value?
        if ($data === 'N;') {
            return null;
        }

        $length = strlen($data);

        // Check some basic requirements of all serialized strings
        if (self::checkBasic($data, $length)) {
            return $data;
        }

        // $data is the serialized false value
        if ($data === 'b:0;') {
            return false;
        }

        // Don't attempt to unserialize data that isn't serialized
        $uns = @unserialize($data, []);

        // Data failed to unserialize?
        if ($uns === false) {
            $uns = @unserialize(self::fix($data), []);

            if ($uns === false) {
                return $data;
            }
            return $uns;
        }

        return $uns;
    }
784953
private static function bcBin2Dec($data) {
	$parts = array(
		unpack('V', substr($data, 12, 4)),
		unpack('V', substr($data, 8, 4)),
		unpack('V', substr($data, 4, 4)),
		unpack('V', substr($data, 0, 4)),
	);

	foreach($parts as &$part)
		if($part[1] < 0)
			$part[1] += 4294967296;

	$result = bcadd(bcadd(bcmul($parts[0][1], bcpow(4294967296, 3)), bcmul($parts[1][1], bcpow(4294967296, 2))), bcadd(bcmul($parts[2][1], 4294967296), $parts[3][1]));

    return $result;
  }
1142291
private function decodePacketHeader($data)
    {
        $ret = array();
        $ret['version']       = ord($data{0});
        $ret['type']          = ord($data{1});
        $ret['requestId']     = (ord($data{2}) << 8) + ord($data{3});
        $ret['contentLength'] = (ord($data{4}) << 8) + ord($data{5});
        $ret['paddingLength'] = ord($data{6});
        $ret['reserved']      = ord($data{7});
        return $ret;
    }
526480
public function write($data)
    {
        $dataLength     = strlen($data);
        $start          = substr($this->buffer, 0, $this->position);
        $end            = substr($this->buffer, $this->position + $dataLength);
        $this->buffer   = $start.$data.$end;
        $this->length   = strlen($this->buffer);
        $this->position += $dataLength;
        return $dataLength;
    }
274841
public function stream_write(string $data): int
    {
        if (self::READONLY === $this->mode) {
            return 0;
        }

        if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
            return 0;
        }

        if (self::$quota->isLimited()) {
            $data = substr($data, 0, self::$quota->spaceLeft(self::$root->sizeSummarized()));
        }

        return $this->content->write($data);
    }
1323724
public static function decode($data)
    {
        $dataLen = strlen($data);

        for ($return = '0', $i = 0; $i < $dataLen; $i++) {
            $current = strpos(self::BASE58_CHARS, $data[$i]);
            $return  = Math::mul($return, '58');
            $return  = Math::add($return, $current);
        }

        $return = Util::encodeHex($return);

        for ($i = 0; $i < $dataLen && substr($data, $i, 1) == '1'; $i++) {
            $return = '00'.$return;
        }

        if (strlen($return) % 2 != 0) {
            $return = '0'.$return;
        }

        return $return;
    }
384207
public function decode($data)
    {
        if ($this->extensionLoaded()) {
            $oData = $data;
            $data = @((\strlen($data) > 0) ? \gzuncompress($data) : '');
            if ($data === false) {
                // Try this fallback
                $tries = 1;
                while ($tries < 10 && ($data === false || \strlen($data) < (\strlen($oData) - $tries - 1))) {
                    $data = @(\gzinflate(\substr($oData, $tries)));
                    $tries++;
                }

                if ($data === false) {
                    // let's try if the checksum is CRC32
                    $fh = fopen('php://temp', 'w+b');
                    \fwrite($fh, "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $oData);
                    \stream_filter_append($fh, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 30]);
                    \fseek($fh, 0);
                    $data = \stream_get_contents($fh);
                    \fclose($fh);
                }

                if (!$data) {
                    throw new FlateException(
                        'Error while decompressing stream.',
                        FlateException::DECOMPRESS_ERROR
                    );
                }
            }
        } else {
            throw new FlateException(
                'To handle FlateDecode filter, enable zlib support in PHP.',
                FlateException::NO_ZLIB
            );
        }

        return $data;
    }
859570
public function read($length)
    {
        $buffer = $this->socket->read($length);

        if ($this->state < self::STATE_OPEN) {
            $this->handshakeBuffer .= $buffer;

            $headerPos = mb_strpos(
                $this->handshakeBuffer,
                "\r\n\r\n",
                0,
                '8bit'
            );

            if ($headerPos !== false) {
                $data = mb_substr(
                    $this->handshakeBuffer,
                    0,
                    $headerPos,
                    '8bit'
                );

                try {
                    $this->handleHandshake($data);
                } catch (Net_Notifier_WebSocket_ProtocolException $e) {
                    $this->state = self::STATE_CLOSED;
                    $this->shutdown();
                }

                $length = mb_strlen($this->handshakeBuffer, '8bit');
                $buffer = mb_substr(
                    $this->handshakeBuffer,
                    $headerPos + 4,
                    $length - $headerPos - 5,
                    '8bit'
                );
            }
        }

        if ($this->state > self::STATE_CONNECTING) {
            $frames = $this->parser->parse($buffer);

            foreach ($frames as $frame) {
                $this->handleFrame($frame);
            }
        }

        return (
               count($this->textMessages) > 0
            || count($this->binaryMessages) > 0
        );
    }
182315
function readByte($byte, $precision = 7)
    {
        $unit  = array('Byte','KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB');

        if (is_numeric($byte)) {
            $w = floor((strlen($byte) - 1) / 3);
            return sprintf("%.{$precision}f %s", $byte/pow(1024, $w), $unit[$w]);
        }
        $str   = array_values(array_filter(explode(' ', $byte)));

        return array_shift($str)*pow(1024,
            (int) array_search(array_shift($str), $unit)).' '.$unit[0];
    }
354776
function read($inByte = null)
    {
        if ($this->getSegmentLimit() == -1)
            return $this->_t__wrap_stream->read($inByte);


        $inByte = ($inByte === null)
            ? (
                ($this->getBuffer() === null) ? $this->getSize() : $this->getBuffer()

            ) : $inByte;

        $remain = $this->getSegmentLimit() - $this->getCurrOffset();
        if ($remain > 0)
            return $this->_t__wrap_stream->read(min($remain, $inByte));

        return '';
    }
1208670
private static function retrievePositiveInteger(string $data): string
    {
        while (0 === \mb_strpos($data, '00', 0, '8bit') && \mb_substr($data, 2, 2, '8bit') > '7f') {
            $data = \mb_substr($data, 2, null, '8bit');
        }

        return $data;
    }
96576
function binaryToLong($str)
    {
        if ($str === null) {
            return null;
        }

        // Use array_merge to return a zero-indexed array instead of a
        // one-indexed array.
        $bytes = array_merge(unpack('C*', $str));

        $n = $this->init(0);

        if ($bytes && ($bytes[0] > 127)) {
            trigger_error("bytesToNum works only for positive integers.",
                          E_USER_WARNING);
            return null;
        }

        foreach ($bytes as $byte) {
            $n = $this->mul($n, pow(2, 8));
            $n = $this->add($n, $byte);
        }

        return $n;
    }
94518
protected function message_read($data)
    {
        $cmd = Utility::ParseCommand(ord($data[0]));
        $message_type = $cmd['message_type'];
        $flags = $cmd['flags'];
        Debug::Log(Debug::DEBUG, "message_read(): message_type=" . Message::$name[$message_type] . ", flags={$flags}");
        Debug::Log(Debug::DEBUG, 'message_read(): Dump', $data);
        $pos = 1;
        $remaining_length = Utility::DecodeLength($data, $pos);
        $message_object = $this->getMessageObject($message_type);
        $message_object->decode($data, $remaining_length);
        return $message_object;
    }
173001
public int readUTF8ByByteLength(char []buffer, int offset, int byteLength)
    throws IOException
  {
    int k = 0;
    for (int i = 0; i < byteLength; i++) {
      if (_readLength <= _readOffset) {
        readBuffer();
      }

      int ch = _readBuffer[_readOffset++] & 0xff;

      if (ch < 0x80) {
        buffer[k++] = (char) ch;
      }
      else if ((ch & 0xe0) == 0xc0) {
        int c2 = read();
        i += 1;
        buffer[k++] = (char) (((ch & 0x1f) << 6) + (c2 & 0x3f));
      }
      else {
        int c2 = read();
        int c3 = read();

        i += 2;
        buffer[k++] = (char) (((ch & 0x1f) << 12)
                              + ((c2 & 0x3f) << 6)
                              + ((c3 & 0x3f)));
      }
    }

    return k;
  }