[Israel.pm] packing and unpacking large numbers
Yona Shlomo
yona at cs.technion.ac.il
Thu Jul 26 05:42:37 PDT 2007
Hello,
I want to be able to represent numbers that are really big
in a Perl program. For example, consider the XML Schema
built in simple type xsd:long, which is a 64 bit integer in
the range [-9223372036854775808,-9223372036854775807] -- I
want to be able to do the following:
1. read and store the scalar
2. use the number in arithmetic operations such as
comparisons, addition, subtraction...
3. pack the number into a C long long int data type (i.e., a
64 bite representation).
#1 shouldn't be a problem, as the scalar
representation will probably remain "as string" until I put
it in a context where Perl will need to convert it to a
numerical value -- right?
#2 should be OK as long as I am consistent using
Math::BigInt.
The problem starts, I think in #3: What should be the proper
way to do this? I noticed that pack() and unpack() don't
have a built in template for long long int.
So -- my question is actually, how do I pack and unpack
numbers that are beyond the scope of an int?
Thanks
--
Shlomo Yona
yona at cs.technion.ac.il
http://yeda.cs.technion.ac.il/~yona/
More information about the Perl
mailing list