ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-porters
perl5-porters
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved