public function readNumber()

in src/Apache/Ignite/Internal/Binary/MessageBuffer.php [189:214]


    public function readNumber(int $type, bool $signed = true)
    {
        $size = BinaryUtils::getSize($type);
        $this->ensureSize($size);
        $strValue = substr($this->buffer, $this->position, $size);
        if ($type === ObjectType::LONG && BinaryUtils::$is32BitInt) {
            // unpack longs doesn't work on 32-bit versions of PHP
            $binValue = strrev($strValue);
            $isNegative = ord($binValue[0]) & 0x80;
            $hexValue = bin2hex($binValue);
            $bigIntValue = BigInteger::parse($hexValue, 16);
            if ($isNegative) {
                $bigIntValue = BigInteger::parse(str_pad('1', $size * 2 + 1, '0'), 16)->minus($bigIntValue);
            }
            $value = $bigIntValue->toFloat();
            if ($isNegative) {
                $value = -$value;
            }
        } else {
            $this->convertEndianness($strValue, $type);
            $value = unpack($this->getNumberFormat($type, $signed), $strValue);
            $value = $value[1];
        }
        $this->position += $size;
        return $value;
    }