Permalink
Browse files

Update Math-BigInt to CPAN version 1.999811

  [DELTA]

2017-03-15 v1.999811 pjacklam

 * Fix an old in the Math::BigFloat methods as_hex(), as_oct(), and as_bin()
   methods resulting in loss of accuracy. This bug was introduced in bug in
   Math-BigInt-1.76. Due to a naive copy and paste by me, and lack of tests,
   this bug was also present in the newer to_hex(), to_oct(), and to_bin()
   methods. This shows the bug, as it did not print "0xffff...":

       print Math::BigFloat -> from_hex("f" x 30) -> as_hex();

 * Fix incorrect formatting in the output from the Math::BigFloat methods
   to_hex(), to_oct(), and to_bin() when the output was zero. A prefix was
   added when it shouldn't have been.

 * Add tests to bigintpm.inc and bigfltpm.inc for better testing of as_hex(),
   as_oct(), and as_bin() as well as to_hex(), to_oct(), and to_bin().

 * "Synchronize" tests and code formatting in bigintpm.inc and bigfltpm.inc.

2017-03-01 v1.999810 pjacklam

 * CPAN RT #120240 revealed that the problems with undefined values is still
   present. After a close examination, I believe the only way to get this
   really working is to to make blog() call objectify() differently depending
   on whether the base for the logarithm is undefined or not. That way we can
   avoid objectify() converting the undefined value to a zero. Ideally, we
   should warn about undefined values when used in any other context, but we'll
   handle that in a later release. See also the related changelog entry for
   v1.999801.

 * Fix the way the argument count is computed in objectify(). When an argument
   count of 0 is given, it means that we should objectify all input arguments.
   However, it turned out that the actual argument count was computed
   incorrectly.

 * Fix CPAN RT #120242 rearding c3 method resolution.

2017-02-10 v1.999809 pjacklam

 * When a new method is added to Math::BigInt or Math::BigFloat, and this new
   method requires a new backend library method, die with a suitable error
   message if the installed backend library does not support this new method.
   The error message says that the method requires a newer version of the
   backend library.

 * Fix typos in Math::BigFloat and Math::BigInt.

 * Add bfib() and blucas() to Math::BigInt. They return Fibonacci and Lucas
   numbers, respectively. The actual computation of the numbers is done by the
   backend library. Documented both methods in POD. Add test files bfib-mbi.t
   and blucas-mbi.t.

 * Add _fib() and _lucas() to Math::BigInt::Lib. They return Fibonacci and
   Lucas numbers, respectively. Document both methods in POD. Add test files
   author-lib-arithmetic-unary-_fib.t and author-lib-arithmetic-unary-_lucas.t.

2017-01-11 v1.999808 pjacklam

 * In Math::BigInt and Math::BigFloat, add methods bdfac() for double
   factorial. Add tests for this method.

 * In Math::BigInt and Math::BigFloat, add methods to_hex(), to_oct(), and
   to_bin() for hexadecimal, octal, and binary string output without prefix.
   Even for Math::BigFloat there is still only support for integer output. Add
   tests for these methods.

 * Add test for as_oct() corresponding to the old tests for as_hex() and
   as_bin().

 * In Math::BigInt::Lib, add method _dfac() for double factorial. Add
   corresponding tests.

 * In Math::BigInt::Lib, fix bug in overloaded "int".

 * In Math::BigInt::Lib, implement much faster versions of _from_hex(),
   _from_oct(), and _from_bin().

 * In Makefile.PL, improve the wording in the message displayed if some of
   the installed backend libraries are not a subclass of Math::BigInt::Lib (and
   hence will not provide

 * Fix minor bugs in some of the author library test files (t/author-lib*.t).

 * Allow leading and trailing whitespace in the input to from_hex(),
   from_oct(), and from_bin().  Add tests to verify. This is a regressions
   (CPAN RT #119805).

2016-12-23 v1.999807 pjacklam

 * Add a message to Makefile.PL recommending upgrade if old libraries are
   installed. This message is more or less equivalent to the one appearing in
   Math-BigInt up until v1.997.

 * Improve the documentation (POD) in Math::BigInt::Lib.

 * Speed up _sqrt() and _root() in Math::BigInt::Lib.

 * Remove checking for exception cases (cases that would return +Inf, -Inf, or
   NaN) in Math::BigInt::Lib. It has been documented for a long time that such
   checking should be done by the caller.

 * Add library methods _to_bin(), _to_oct(), _to_hex(), which are equivalent to
   the _as_bin(), _as_oct(), and _as_hex() methods respectively, except that
   the _to_*() methods don't use a prefix in the output. This removes the need
   for the frequent removal of the various prefixes. Now each _as_*() method
   calls the equivalent _to_*() method, adds a prefix, and returns the output.
   The _to_*() methods are faster than the equivalent _as_*() methods were.

 * Add author test files for the methods _to_bin(), _to_oct(), and _to_hex().

 * Add library method _to_bytes(). The method _as_bytes() would have been
   called _to_bytes() if I had thought of it earlier. The method _as_bytes() is
   now just an alias to _to_bytes(). The _to_bytes() method also fixes a bug
   that was present in the _as_bytes() method. (CPAN RT #119346).

 * Add author test files for the method _to_bytes().

 * Add more tests for library methods _inc() and _dec(). When trying to bring
   the Math::BigInt::BitVect library back to life I realized that the test
   suite didn't catch certain errors in _inc() and _dec().

 * Die if trying to use as_bytes() or from_bytes() with a backend library that
   doesn't support the corresponding library methods.

 * Correct minor errors in the output messages in the test files.

 * Improve/correct various comments in the source code.

 * More diagnostic output is displayed by the author test files if the
   AUTHOR_DEBUGGING environment variable is set.
  • Loading branch information...
bingos committed Sep 22, 2017
1 parent 72807c7 commit efb0a80c0b4264c8cba8bd9067350c2659fe49d4
View
@@ -1721,6 +1721,7 @@ cpan/Math-BigInt/t/bdstr-mbf.t Test Math::BigInt
cpan/Math-BigInt/t/bdstr-mbi.t Test Math::BigInt
cpan/Math-BigInt/t/bestr-mbf.t Test Math::BigInt
cpan/Math-BigInt/t/bestr-mbi.t Test Math::BigInt
cpan/Math-BigInt/t/bfib-mbi.t
cpan/Math-BigInt/t/big_pi_e.t test bpi() and bexp()
cpan/Math-BigInt/t/bigfltpm.inc Shared tests for bigfltpm.t and sub_mbf.t
cpan/Math-BigInt/t/bigfltpm.t See if BigFloat.pm works
@@ -1730,6 +1731,7 @@ cpan/Math-BigInt/t/bigintpm.t See if BigInt.pm works
cpan/Math-BigInt/t/bigints.t See if BigInt.pm works
cpan/Math-BigInt/t/biglog.t Test the log function
cpan/Math-BigInt/t/bigroot.t Test the broot function
cpan/Math-BigInt/t/blucas-mbi.t
cpan/Math-BigInt/t/bnstr-mbf.t Test Math::BigInt
cpan/Math-BigInt/t/bnstr-mbi.t Test Math::BigInt
cpan/Math-BigInt/t/bsstr-mbf.t Test Math::BigInt
View
@@ -710,7 +710,7 @@ package Maintainers;
},
'Math::BigInt' => {
'DISTRIBUTION' => 'PJACKLAM/Math-BigInt-1.999806.tar.gz',
'DISTRIBUTION' => 'PJACKLAM/Math-BigInt-1.999811.tar.gz',
'FILES' => q[cpan/Math-BigInt],
'EXCLUDED' => [
qr{^examples/},
@@ -19,7 +19,7 @@ use warnings;
use Carp ();
use Math::BigInt ();
our $VERSION = '1.999806';
our $VERSION = '1.999811';
require Exporter;
our @ISA = qw/Math::BigInt/;
@@ -529,6 +529,7 @@ sub from_hex {
if ($str =~ s/
^
\s*
# sign
( [+-]? )
@@ -555,6 +556,7 @@ sub from_hex {
( \d+ (?: _ \d+ )* )
)?
\s*
$
//x)
{
@@ -618,6 +620,7 @@ sub from_oct {
if ($str =~ s/
^
\s*
# sign
( [+-]? )
@@ -641,6 +644,7 @@ sub from_oct {
( \d+ (?: _ \d+ )* )
)?
\s*
$
//x)
{
@@ -704,6 +708,7 @@ sub from_bin {
if ($str =~ s/
^
\s*
# sign
( [+-]? )
@@ -730,6 +735,7 @@ sub from_bin {
( \d+ (?: _ \d+ )* )
)?
\s*
$
//x)
{
@@ -2137,16 +2143,24 @@ sub bpow {
}
sub blog {
my ($class, $x, $base, $a, $p, $r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(2, @_);
# Return the logarithm of the operand. If a second operand is defined, that
# value is used as the base, otherwise the base is assumed to be Euler's
# constant.
# If called as $x -> blog() or $x -> blog(undef), don't objectify the
# undefined base, since undef signals that the base is Euler's number.
#unless (ref($x) && !defined($base)) {
# # objectify is costly, so avoid it
# if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1]))) {
# ($class, $x, $base, $a, $p, $r) = objectify(2, @_);
# }
#}
my ($class, $x, $base, $a, $p, $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.
if (!ref($_[0]) && $_[0] =~ /^[A-Za-z]|::/) {
# E.g., Math::BigFloat->blog(256, 2)
($class, $x, $base, $a, $p, $r) =
defined $_[2] ? objectify(2, @_) : objectify(1, @_);
} else {
# E.g., Math::BigFloat::blog(256, 2) or $x->blog(2)
($class, $x, $base, $a, $p, $r) =
defined $_[1] ? objectify(2, @_) : objectify(1, @_);
}
return $x if $x->modify('blog');
@@ -3226,7 +3240,6 @@ sub bfac {
if (($x->{sign} ne '+') || # inf, NaN, <0 etc => NaN
($x->{_es} ne '+')); # digits after dot?
# use BigInt's bfac() for faster calc
if (! $MBI->_is_zero($x->{_e})) {
$x->{_m} = $MBI->_lsft($x->{_m}, $x->{_e}, 10); # change 12e1 to 120e0
$x->{_e} = $MBI->_zero(); # normalize
@@ -3236,6 +3249,33 @@ sub bfac {
$x->bnorm()->round(@r); # norm again and round result
}
sub bdfac {
# compute double factorial
# set up parameters
my ($class, $x, @r) = (ref($_[0]), @_);
# objectify is costly, so avoid it
($class, $x, @r) = objectify(1, @_) if !ref($x);
# inf => inf
return $x if $x->modify('bfac') || $x->{sign} eq '+inf';
return $x->bnan()
if (($x->{sign} ne '+') || # inf, NaN, <0 etc => NaN
($x->{_es} ne '+')); # digits after dot?
Carp::croak("bdfac() requires a newer version of the $MBI library.")
unless $MBI->can('_dfac');
if (! $MBI->_is_zero($x->{_e})) {
$x->{_m} = $MBI->_lsft($x->{_m}, $x->{_e}, 10); # change 12e1 to 120e0
$x->{_e} = $MBI->_zero(); # normalize
$x->{_es} = '+';
}
$x->{_m} = $MBI->_dfac($x->{_m}); # calculate factorial
$x->bnorm()->round(@r); # norm again and round result
}
sub blsft {
# shift left by $y (multiply by $b ** $y)
@@ -3999,8 +4039,63 @@ sub bestr {
return $mant . 'e' . $esgn . $eabs;
}
sub to_hex {
# return number as hexadecimal string (only for integers defined)
my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_);
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
return '0' if $x->is_zero();
return $nan if $x->{_es} ne '+'; # how to do 1e-1 in hex?
my $z = $MBI->_copy($x->{_m});
if (! $MBI->_is_zero($x->{_e})) { # > 0
$z = $MBI->_lsft($z, $x->{_e}, 10);
}
my $str = $MBI->_to_hex($z);
return $x->{sign} eq '-' ? "-$str" : $str;
}
sub to_oct {
# return number as octal digit string (only for integers defined)
my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_);
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
return '0' if $x->is_zero();
return $nan if $x->{_es} ne '+'; # how to do 1e-1 in octal?
my $z = $MBI->_copy($x->{_m});
if (! $MBI->_is_zero($x->{_e})) { # > 0
$z = $MBI->_lsft($z, $x->{_e}, 10);
}
my $str = $MBI->_to_oct($z);
return $x->{sign} eq '-' ? "-$str" : $str;
}
sub to_bin {
# return number as binary digit string (only for integers defined)
my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_);
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
return '0' if $x->is_zero();
return $nan if $x->{_es} ne '+'; # how to do 1e-1 in binary?
my $z = $MBI->_copy($x->{_m});
if (! $MBI->_is_zero($x->{_e})) { # > 0
$z = $MBI->_lsft($z, $x->{_e}, 10);
}
my $str = $MBI->_to_bin($z);
return $x->{sign} eq '-' ? "-$str" : $str;
}
sub as_hex {
# return number as hexadecimal string (only for integers defined)
my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_);
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
@@ -4012,29 +4107,31 @@ sub as_hex {
if (! $MBI->_is_zero($x->{_e})) { # > 0
$z = $MBI->_lsft($z, $x->{_e}, 10);
}
$z = Math::BigInt->new($x->{sign} . $MBI->_num($z));
$z->as_hex();
my $str = $MBI->_as_hex($z);
return $x->{sign} eq '-' ? "-$str" : $str;
}
sub as_oct {
# return number as octal digit string (only for integers defined)
my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_);
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
return '0' if $x->is_zero();
return '00' if $x->is_zero();
return $nan if $x->{_es} ne '+'; # how to do 1e-1 in octal?
my $z = $MBI->_copy($x->{_m});
if (! $MBI->_is_zero($x->{_e})) { # > 0
$z = $MBI->_lsft($z, $x->{_e}, 10);
}
$z = Math::BigInt->new($x->{sign} . $MBI->_num($z));
$z->as_oct();
my $str = $MBI->_as_oct($z);
return $x->{sign} eq '-' ? "-$str" : $str;
}
sub as_bin {
# return number as binary digit string (only for integers defined)
my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_);
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
@@ -4046,8 +4143,8 @@ sub as_bin {
if (! $MBI->_is_zero($x->{_e})) { # > 0
$z = $MBI->_lsft($z, $x->{_e}, 10);
}
$z = Math::BigInt->new($x->{sign} . $MBI->_num($z));
$z->as_bin();
my $str = $MBI->_as_bin($z);
return $x->{sign} eq '-' ? "-$str" : $str;
}
sub numify {
Oops, something went wrong.

0 comments on commit efb0a80

Please sign in to comment.