Skip Menu |

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 22122
Status: resolved
Worked: 25 min
Priority: 0/
Queue: Math-BigInt

Owner: TELS [...]
Requestors: leonerd-cpan [...]

Bug Information
Severity: Normal
Broken in: 1.77
Fixed in: 1.78

Subject: Does not recognise octal constants
Download (untitled) / with headers
text/plain 835b
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
Download (untitled) / with headers
text/plain 211b
I am sorry, but this cannot be implemented that way, because ->new("0123") must result in 123 for backwards compatibility reasons. However, one could add a from_octal() method. Would you write a patch for that?
Download (untitled) / with headers
text/plain 153b
Hm, after thinking about this, you are probably right: # perl -Mbignum -le 'print 0123 + 12' 135 # perl -le 'print 0123 + 12' 95 Best wishes, Tels
This issue has been fixed in the released v1.78. Thank you for your report, Tels

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to