summaryrefslogtreecommitdiff
path: root/lib/Math/BigFloat.pm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-20 17:54:15 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-20 17:54:15 +0000
commit7596a890808c68b396a85f42b3695b1e97cbe208 (patch)
tree7ac0b2671ac6feb8bf2581d0ab0c12e7599af9ae /lib/Math/BigFloat.pm
parent90ce55a189f2bdb2d042b4e4190bf41cd6331190 (diff)
downloadperl-7596a890808c68b396a85f42b3695b1e97cbe208.tar.gz
Upgrade to Math::BigInt 1.77
p4raw-id: //depot/perl@24517
Diffstat (limited to 'lib/Math/BigFloat.pm')
-rw-r--r--lib/Math/BigFloat.pm20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Math/BigFloat.pm b/lib/Math/BigFloat.pm
index 2300ae480c..4830618b51 100644
--- a/lib/Math/BigFloat.pm
+++ b/lib/Math/BigFloat.pm
@@ -12,7 +12,7 @@ package Math::BigFloat;
# _a : accuracy
# _p : precision
-$VERSION = '1.50';
+$VERSION = '1.51';
require 5.005;
require Exporter;
@@ -197,7 +197,8 @@ sub new
my $z = $MBI->_new($zeros);
# turn '120e2' into '12e3'
$MBI->_rsft ( $self->{_m}, $z, 10);
- _e_add ( $self->{_e}, $z, $self->{_es}, '+');
+ ($self->{_e}, $self->{_es}) =
+ _e_add ( $self->{_e}, $z, $self->{_es}, '+');
}
}
$self->{sign} = $$mis;
@@ -1339,12 +1340,14 @@ sub bdiv
# already handled inf/NaN/-inf above:
- my $xsign = $x->{sign};
- $y->{sign} =~ tr/+-/-+/;
-
# check that $y is not 1 nor -1 and cache the result:
my $y_not_one = !($MBI->_is_zero($y->{_e}) && $MBI->_is_one($y->{_m}));
+ # flipping the sign of $y will also flip the sign of $x for the special
+ # case of $x->bsub($x); so we can catch it below:
+ my $xsign = $x->{sign};
+ $y->{sign} =~ tr/+-/-+/;
+
if ($xsign ne $x->{sign})
{
# special case of $x /= $x results in 1
@@ -1443,9 +1446,10 @@ sub bmod
return $x;
}
- return $x->bzero() if $x->is_zero() ||
- # check that $y == -1 or +1:
- ($MBI->_is_zero($y->{_e}) && $MBI->_is_one($y->{_m}));
+ return $x->bzero() if $x->is_zero()
+ || ($x->is_int() &&
+ # check that $y == +1 or $y == -1:
+ ($MBI->_is_zero($y->{_e}) && $MBI->_is_one($y->{_m})));
my $cmp = $x->bacmp($y); # equal or $x < $y?
return $x->bzero($a,$p) if $cmp == 0; # $x == $y => result 0