in reply to Re^4: Number too big to fit in integer
in thread Number too big to fit in integer

Ok, there has been a change somewhere along the line: if I compare "n more than ~0" against "~0" for integer n, up to 5.28 it first compares different for n = 2985 (ie with 18446744073709554600); with 5.30 and later it first compares different for n = 2050 (ie with 18446744073709553665):

% /opt/v5.28.1/bin/perl -MMath::BigInt -we '$z0 = Math::BigInt->new(~0 +); for (1..4096) { $z1 = $z0 + $_; $n1 = "$z1"; die $_ if $n1 != ~0 } +' 2985 at -e line 1. % /opt/v5.30.0-d/bin/perl -MMath::BigInt -we '$z0 = Math::BigInt->new( +~0); for (1..4096) { $z1 = $z0 + $_; $n1 = "$z1"; die $_ if $n1 != ~0 + }' 2050 at -e line 1. %

(From the naming I know that's a v5.30.0 built with debugging, but that shouldn't make a difference here.)

Replies are listed 'Best First'.
Re^6: Number too big to fit in integer
by syphilis (Archbishop) on Jan 01, 2023 at 09:40 UTC
    Ok, there has been a change somewhere along the line:

    Yes - beginning with perl-5.30.0, perl uses C's strtod() to assign values, instead of its own (buggy) atof routine that it had previously been using.
    That fixed many errors in assignment - eg https://github.com/Perl/perl5/issues/8730, which had been reported in Jan 2007.

    Cheers,
    Rob