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

An XDR double precision floating point number is encoded into eight bytes using the IEEE standard for floating point numbers.

To encode a double precision floating point number:

use StageRightLabs\PhpXdr\XDR;

// Encode
$xdr = XDR::fresh()->write(3.1425, XDR::DOUBLE);

To decode a double precision floating point number:

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

// Decode
$float = $xdr->read(XDR::DOUBLE); // ~3.1415

NB: It is likely that you will run into precision errors when decoding floating point values: https://floating-point-gui.de/errors/comparison/