This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Math-BigRat to CPAN version 0.2613
[perl5.git] / cpan / Math-BigRat / lib / Math / BigRat.pm
index c604a27..520b443 100644 (file)
@@ -18,9 +18,9 @@ use warnings;
 
 use Carp ();
 
-use Math::BigFloat '1.999718';
+use Math::BigFloat 1.999718;
 
-our $VERSION = '0.2611';
+our $VERSION = '0.2613';
 
 our @ISA = qw(Math::BigFloat);
 
@@ -887,9 +887,11 @@ sub bmul {
     my $gcd_sq = $LIB -> _gcd($LIB -> _copy($y->{_n}), $x->{_d});
 
     $x->{_n} = $LIB -> _mul(scalar $LIB -> _div($x->{_n}, $gcd_pr),
-                            scalar $LIB -> _div($y->{_n}, $gcd_sq));
+                            scalar $LIB -> _div($LIB -> _copy($y->{_n}),
+                                                $gcd_sq));
     $x->{_d} = $LIB -> _mul(scalar $LIB -> _div($x->{_d}, $gcd_sq),
-                            scalar $LIB -> _div($y->{_d}, $gcd_pr));
+                            scalar $LIB -> _div($LIB -> _copy($y->{_d}),
+                                                $gcd_pr));
 
     # compute new sign
     $x->{sign} = $x->{sign} eq $y->{sign} ? '+' : '-';
@@ -1348,15 +1350,19 @@ sub blog {
     # value is used as the base, otherwise the base is assumed to be Euler's
     # constant.
 
+    my ($class, $x, $base, @r);
+
     # Don't objectify the base, since an undefined base, as in $x->blog() or
     # $x->blog(undef) signals that the base is Euler's number.
 
-    # set up parameters
-    my ($class, $x, $base, @r) = (ref($_[0]), @_);
-
-    # objectify is costly, so avoid it
-    if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1]))) {
-        ($class, $x, $base, @r) = objectify(1, @_);
+    if (!ref($_[0]) && $_[0] =~ /^[A-Za-z]|::/) {
+        # E.g., Math::BigFloat->blog(256, 2)
+        ($class, $x, $base, @r) =
+          defined $_[2] ? objectify(2, @_) : objectify(1, @_);
+    } else {
+        # E.g., Math::BigFloat::blog(256, 2) or $x->blog(2)
+        ($class, $x, $base, @r) =
+          defined $_[1] ? objectify(2, @_) : objectify(1, @_);
     }
 
     return $x if $x->modify('blog');
@@ -1417,7 +1423,7 @@ sub bexp {
 
     # objectify is costly, so avoid it
     if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1]))) {
-        ($class, $x, $y, @r) = objectify(2, @_);
+        ($class, $x, $y, @r) = objectify(1, @_);
     }
 
     return $x->binf(@r)  if $x->{sign} eq '+inf';