Depending on how perl is built, int's are either 32 or 64 bits. The core Math::BigInt module allows the use of effectively unlimited size integers.
| [reply] |
Use Math::BigInt to let them grow unboundedly. (This module underwent a major rewrite at one point. Use the version shipped with perl 5.8 or later; for earlier perl versions, get a copy from CPAN).
Normally, perl uses a 32 or 64 bit signed integer (depending on platform and Configure options), promoting it to a floating point value (usually with 53 or 64 bits of mantissa)/ as needed. To stretch just a little extra range for integers, perl will sometimes use an unsigned integer instead of a signed one. | [reply] |
| [reply] |
Even with one of the XS libraries, it'll be a lot slower.
| [reply] |
| [reply] |
No, it's certainly *not* the same as C ints, and it's not
necessarely directly related to size of registers on the
hardware. For internal integers, you can
get 32 bit or 64 bit integers (or perhaps even 128 bit
integers) if your C compiler supports it.
But under normal conditions, Perl (the language) doesn't have
integers. It has numerical values. They may internally represented by integers, but if the need arises, they are
seemlessly upgraded to floats. And you need to jump to some
hoops to find out the internal representation. The precision
of floats may vary from platform to platform, but it's typically 64 bits. This means that if your perl uses 32 bit
integers internally, Perl (the language) still is able to
deal with integer numbers of around 53 bits without losing
precision.
Abigail
| [reply] |