as_int() is an alias for as_number(), and the bug was in the as_number()
subroutine in Math::BigFloat. I have attached a patch that fixes the
bug. Test are added that verify the behaviour. Hope you like it.
diff -ur Math-BigInt-1.96-orig/lib/Math/BigFloat.pm Math-BigInt-1.96/lib/Math/BigFloat.pm
--- Math-BigInt-1.96-orig/lib/Math/BigFloat.pm 2010-09-28 06:34:04.000000000 +0200
+++ Math-BigInt-1.96/lib/Math/BigFloat.pm 2010-10-13 12:24:10.703125000 +0200
@@ -3684,6 +3684,9 @@
$x = $x->can('as_float') ? $x->as_float() : $self->new(0+"$x");
}
+ return Math::BigInt->binf($x->sign()) if $x->is_inf();
+ return Math::BigInt->bnan() if $x->is_nan();
+
my $z = $MBI->_copy($x->{_m});
if ($x->{_es} eq '-') # < 0
{
diff -ur Math-BigInt-1.96-orig/t/bigfltpm.inc Math-BigInt-1.96/t/bigfltpm.inc
--- Math-BigInt-1.96-orig/t/bigfltpm.inc 2010-09-13 16:28:42.000000000 +0200
+++ Math-BigInt-1.96/t/bigfltpm.inc 2010-10-13 12:26:25.265625000 +0200
@@ -587,6 +587,9 @@
-2:-2
-123.456:-123
-200:-200
+-inf:-inf
+inf:inf
+NaN:NaN
# test for bug in brsft() not handling cases that return 0
0.000641:0
0.0006412:0
diff -ur Math-BigInt-1.96-orig/t/bigfltpm.t Math-BigInt-1.96/t/bigfltpm.t
--- Math-BigInt-1.96-orig/t/bigfltpm.t 2010-09-13 16:28:42.000000000 +0200
+++ Math-BigInt-1.96/t/bigfltpm.t 2010-10-13 12:26:57.140625000 +0200
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 2316
+use Test::More tests => 2319
+ 5; # own tests