my $class = "Math::BigInt";
require 5.005;
+# This is a patched v1.60, containing a fix for the "1234567890\n" bug
$VERSION = '1.60';
use Exporter;
@ISA = qw( Exporter );
my $self = bless {}, $class;
# shortcut for "normal" numbers
- if ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*$/))
+ if ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*\z/))
{
$self->{sign} = $1 || '+';
my $ref = \$wanted;
$$x =~ s/\s+$//g; # strip white space at end
# shortcut, if nothing to split, return early
- if ($$x =~ /^[+-]?\d+$/)
+ if ($$x =~ /^[+-]?\d+\z/)
{
$$x =~ s/^([+-])0*([0-9])/$2/; my $sign = $1 || '+';
return (\$sign, $x, \'', \'', \0);
=over 2
-=item Input with trailing newlines
-
-Input with trailing newlines is handled wrong (e.g. lead to corrupted numbers)
-in some cases, for instance "123\n" or "123456789\n".
-
=item Out of Memory!
Under Perl prior to 5.6.0 having an C<use Math::BigInt ':constant';> and
-inf:NaN:
NaN:-inf:
&bnorm
+-0\n:0
+-123\n:-123
+-1234\n:-1234
+-12345\n:-12345
+-123456\n:-123456
+-1234567\n:-1234567
+-12345678\n:-12345678
+-123456789\n:-123456789
+-1234567890\n:-1234567890
+-12345678901\n:-12345678901
+0\n:0
+123\n:123
+1234\n:1234
+12345\n:12345
+123456\n:123456
+1234567\n:1234567
+12345678\n:12345678
+123456789\n:123456789
+1234567890\n:1234567890
+12345678901\n:12345678901
+\n0:0
+\n123:123
+\n1234:1234
+\n12345:12345
+\n123456:123456
+\n1234567:1234567
+\n12345678:12345678
+\n123456789:123456789
+\n1234567890:1234567890
+\n12345678901:12345678901
+\n0\n:0
+\n123\n:123
+\n1234\n:1234
+\n12345\n:12345
+\n123456\n:123456
+\n1234567\n:1234567
+\n12345678\n:12345678
+\n123456789\n:123456789
+\n1234567890\n:1234567890
+\n12345678901\n:12345678901
+\t0\n:0
+\t123\n:123
+\t1234\n:1234
+\t12345\n:12345
+\t123456\n:123456
+\t1234567\n:1234567
+\t12345678\n:12345678
+\t123456789\n:123456789
+\t1234567890\n:1234567890
+\t12345678901\n:12345678901
+\n0\t:0
+\n123\t:123
+\n1234\t:1234
+\n12345\t:12345
+\n123456\t:123456
+\n1234567\t:1234567
+\n12345678\t:12345678
+\n123456789\t:123456789
+\n1234567890\t:1234567890
+\n12345678901\t:12345678901
+0\n\n:0
+123\n\n:123
+1234\n\n:1234
+12345\n\n:12345
+123456\n\n:123456
+1234567\n\n:1234567
+12345678\n\n:12345678
+123456789\n\n:123456789
+1234567890\n\n:1234567890
+12345678901\n\n:12345678901
+\n\n0:0
+\n\n123:123
+\n\n1234:1234
+\n\n12345:12345
+\n\n123456:123456
+\n\n1234567:1234567
+\n\n12345678:12345678
+\n\n123456789:123456789
+\n\n1234567890:1234567890
+\n\n12345678901:12345678901
123:123
# binary input
0babc:NaN