in reply to Re: big integers forcing me to be a C programmer: "range iterator outside integer range"
in thread big integers forcing me to be a C programmer: "range iterator outside integer range"

but you just have to create $x in a slightly different way

No you don't. The direct equivalent works just fine.

>perl -MMath::BigInt -le"my $x = Math::BigInt->new(2) ** Math::BigInt- +>new(1024); print $x" 1797693134862315907729305190789024733617976978942306572734300811577326 +758055009631327084773224075360211201138798713933576587897688144166224 +928474306394741243777678934248654852763022196012460941194530829520850 +057688381506823424628814739131105408272371633505106845862982399472459 +38479716304835356329624224137216

It can even be simplified

>perl -MMath::BigInt -le"my $x = Math::BigInt->new(2) ** 1024; print $ +x" 1797693134862315907729305190789024733617976978942306572734300811577326 +758055009631327084773224075360211201138798713933576587897688144166224 +928474306394741243777678934248654852763022196012460941194530829520850 +057688381506823424628814739131105408272371633505106845862982399472459 +38479716304835356329624224137216
  • Comment on Re^2: big integers forcing me to be a C programmer: "range iterator outside integer range"
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: big integers forcing me to be a C programmer: "range iterator outside integer range"
by syphilis (Archbishop) on May 07, 2009 at 11:30 UTC
    The direct equivalent works just fine

    I was thinking that the "direct equivalent" would be:
    my $x = Math::BigInt->new(2**1024);
    which doesn't work quite so well :-)

    Cheers,
    Rob
      bignum converts every numeric literal into a Math::Big* object. That would even include the "2" in the for loop, although that one can also be skipped.