Perl has long been my choice scripting language but I’ve run into a horrible problem. By default there is no support for long (64 bit) integers. Most of the time an integer is just a string and they work for seeking in huge files but there are plenty of places they don’t work, such as binary &, printf, pack, unpack, <<, >>.
Now these do work in newer versions of Perl but only if it is built with 64-bit integer support, which does not help if I want to make portable code to run on Perls built without this option. And you don’t always get control over the Perl on a system your code runs on.
My question is do Python, PHP, and Ruby suffer from such a problem, or do they also depend on version and build options?
The size of high speed hardware integers (assuming the language has them) will always be dependent on whatever size integers are available to the compiler that compiled the language interpreter (usually C).
If you need cross-platform / cross-version big integer support, the Perl pragma
use bigint;will do the trick. If you need more control,bigintis a wrapper around the moduleMath::BigInt.In the scope where
use bigint;is loaded, all of the integers in that scope will be transparently upgraded toMath::BigIntnumbers. Lastly, when using any sort of big number library, be sure to not use tricks like9**9**9to get infinity, because you might be waiting a while 🙂