in reply to integer container for float
You can check that a native int will hold a native double:
use Config; die "Int/double size mismatch" unless $Config{ ivsize } == $Config{ nv +size };
And if you get passed that test, then the following should always work:
$packedDoubleAsInt = unpack 'Q', pack 'd', 3.14159265358979;; print $packedDoubleAsInt;; 4614256656552045841 $unpacked = unpack 'd', pack 'Q', $packedDoubleAsInt;; print $unpacked;; 3.14159265358979 $unpacked = unpack 'd', pack 'Q', 4614256656552045841;; print $unpacked;; 3.14159265358979
|
|---|