Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • FWIW this also works fine when 64-bit ints are compiled in -- which IMO should be the default whenever it's available.
    • Oh, I hadn't thought of that. I wonder if it's just that Perl hasn't been built with 64-bit support but the others have.
      • by btilly (5037) on 2007.10.24 19:10 (#58566) Journal
        No, it is not how the language is compiled.

        Ruby borrowed an idea from Smalltalk. Small integers are of type Fixnum, and it automatically promotes results above about a billion to Bignum on the fly. (IIRC, it has to reserve one bit for the sign and one for some internal bookkeeping.) As a result integer operations with Ruby are always exact. There is some overhead for this scheme, but there are tricks that make it less than you think. (Again, these tricks were worked out for Smalltalk.)

        Given that Python and Ruby both give the same answer for 2**100 & 3**100 (namely 1267650600228229401496703205376) I'm confident that Python is doing exact arithmetic as well.