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

People
Owner: TELS [...] cpan.org
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

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



Subject: Does not recognise octal constants
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 835
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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-25785-1169813086-1931.22122-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 211
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?
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-25745-1169813214-914.22122-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 153
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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-4362-1170421636-117.22122-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 82
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 Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.