Skip to content
Ryan Durham edited this page Nov 26, 2021 · 4 revisions

A "hyper" integer is a signed 64 bit value. Hyper integers are allocated 8 bytes of storage in the XDR buffer, whereas regular integers are only allocated 4 bytes.

To encode a hyper integer:

use StageRightLabs\PhpXdr\XDR;

// Encode
$xdr = XDR::fresh()->write(42000000000, XDR::HYPER_INT);

To decode a hyper integer:

use StageRightLabs\PhpXdr\XDR;
$xdr = XDR::fresh()->write(42000000000, XDR::INT);

// Decode
$int = $xdr->read(XDR::HYPER_INT); // 42000000000

To encode a hyper unsigned integer:

use StageRightLabs\PhpXdr\XDR;

// Encode
$xdr = XDR::fresh()->write(42000000000, XDR::HYPER_UINT);

To decode a hyper unsigned integer:

use StageRightLabs\PhpXdr\XDR;
$xdr = XDR::fresh()->write(42000000000, XDR::INT);

// Decode
$int = $xdr->read(XDR::HYPER_UINT); // 42000000000

NB: Make sure you understand the numerical limitations of PHP before attempting to work with a value that exceeds PHP_INT_MAX or PHP_INT_MIN on your system.