Subject: | Does not recognise octal constants |
Consdier:
use bigint;
my $i = 0755;
printf "%o oct, %d dec\n", $i, $i;
This produces
1363 oct, 755 dec
Rather than (without 'use bigint'):
755 oct, 493 dec
I have determined this to be a bug in Math::BigInt's constructor:
my $i = Math::BigInt->new( "0755" );
printf "%o oct, %d dec\n", $i, $i;
1363 oct, 755 dec
Looking over the code, it appears that the "is this a decimal integer"
regexp fails:
if ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*\z/))
So the next thing it tries is the _split() function, which tries:
return __from_hex($x) if $x =~ /^[\-\+]?0x/; # hex string
return __from_bin($x) if $x =~ /^[\-\+]?0b/; # binary string
Perhaps another line here should be added,
return __from_oct($x) if $x =~ m/^[\-\+]?0/; # octal string
and a suitable __from_oct function written?
--
Paul Evans