Re: pack "q" in 32-bit environments
by Marcus Holland-Moritz other posts by this author
Jul 18 2008 1:30AM messages near this date
pack "q" in 32-bit environments
|
Re: pack "q" in 32-bit environments
Hello Ted,
On 2008-07-17, at 10:11:26 -0500, Ted Zlatanov wrote:
> Is there a reason the pack "q" template requires 64-bit Perl? It seems
> like it should be available (in a simulated, not native form) on 32-bit
> as well.
How would you suggest that "simulation" to work?
The primary problem is that the only way to preserve the
full resolution of a 64-bit integer on a 32-bit perl is
to store it as a string. (That's what I'm doing in the
Convert::Binary::C module.)
However, as soon as you start using that string in numeric
context, it will be converted to an IV (integer) or NV
(float), depending on the value, so you may lose precision.
This is certainly doable, but I'm not sure whether or not
that is something we want in the core, as it's not very
DWIMmy:
mhx@r2d2 ~ $ perl -MConvert::Binary::C -le'print Convert::Binary::C-> new->unpack("long lon
g", "aaaaaaaa")'
7016996765293437281
mhx@r2d2 ~ $ perl -MConvert::Binary::C -le'printf "%d\n", Convert::Binary::C-> new->unpack(
"long long", "aaaaaaaa")'
-1
mhx@r2d2 ~ $ perl -MConvert::Binary::C -le'printf "%f\n", Convert::Binary::C-> new->unpack(
"long long", "aaaaaaaa")'
7016996765293437952.000000
Marcus
--
party, n.:
A gathering where you meet people who drink
so much you can't even remember their names.
Thread:
Ted Zlatanov
Marcus Holland-Moritz
Ted Zlatanov
|