Commit 43612245 authored by Angel Abad's avatar Angel Abad

New upstream version 1.999726

parent 92e20f72
......@@ -1695,7 +1695,7 @@ there are so many changes, I let this be a development release.
step along the way to a pure object oriented design.
* When bnan() and binf() are used as instance methods, they no longer delete
the accuracy and precision instance variables.
the accuracy and precision instance variables.
* Add test files from_bin-mbf.t, from_oct-mbf.t, and new-mbf.t.
......@@ -1773,7 +1773,97 @@ there are so many changes, I let this be a development release.
warnings about using an unitialized variable. This fix applies to both
Math::BigInt and Math::BigFloat.
Please send us test-reports, your experiences with this and your ideas - we love
to hear about our work!
2016-06-09 v1.999723 pjacklam
* Add Math::BigInt and Math::BigFloat methods bnstr(), bestr(), and bdstr(),
as well as corresponding methods nparts(), eparts(), and dparts(). Also add
test files bdstr-mbf.t, bdstr-mbi.t, bestr-mbf.t, bestr-mbi.t, bnstr-mbf.t,
bnstr-mbi.t, bsstr-mbf.t, bsstr-mbi.t, dparts-mbf.t, dparts-mbi.t,
eparts-mbf.t, eparts-mbi.t, nparts-mbf.t, nparts-mbi.t, sparts-mbf.t, and
sparts-mbi.t.
* Fix documentation errors.
2016-06-19 v1.999724 pjacklam
* In Math/BigInt.pm and Math/BigFloat.pm, correct and improve to the
documentation, e.g., reorder the methods so that methods that belogin
together are grouped together.
* In Math/BigInt.pm and Math/BigFloat.pm, refactor the code so that methods
that belong together are grouped together. Also use consistent code
formatting.
* In Math/BigInt/Calc.pm, reformat the code.
2016-07-13 v1.999725 pjacklam
Changes:
* Add method is_finite().
* In Math::BigInt and Math::BigFloat, remove warnings about deprecated usage,
at least until we have removed this usage from the "bignum" distribution.
These warnings were too annoying for some people.
Improvements:
* Faster bnok() when the library (backend) does not support it.
* In the Math::BigFloat method bpi(), use a precomputed list of digits when
the accuracy is <= 1000. This speeds up the trigonometric functions
considerably, when I will introduce range reduction in a later release. This
makes the _atan_inv() method redundant, so remove it. Also, the _alen()
library method is now only used in _log_int(), which is good, because it
isn't clear from the docs and tests what it was supposed to do.
Fixes:
* Fix bug in the Math::BigInt::Calc library method _digit(). It would
sometimes return undef or an empty string when it should have returned zero.
* Fix bug in the Math::BigInt::Calc library method _rsft(). It would sometimes
return two output arguments.
* Fix bug in the Math::BigInt::Calc library method _lsft(). When the number
zero was shifted N places in base 10, the result was not zero, but an
invalid object.
* Fix bug in the Math::BigInt::Calc library methods _and(), _or(), and _xor().
They always assigned zero to the first input argument (the invocand).
* Improve the Math::BigInt::Calc library method _log_int() for the cases when
the output is zero or one. Also simplify the code.
* Simplify the code for the Math::BigInt::Calc library method _zeros().
* Reformat Math::BigInt::Calc so it is easier to read, for me anyway.
* Add file t/author-bnok-mbi.t
* Add one test file for every method in the libraries, including
t/Math/BigInt/Lib/TestUtil.pm with test utilities.
* Clean up whitespace in all files in the distribution.
* Better testing in t/author-bpi-mbf.t
* The Math::BigInt::Calc library now always uses integers inside the objects,
so there is no longer any need for all the "0 + ..." to convert strings to
numbers, and the "int()" inside "length(int(...))" to determine the length
of an array element. The only case that needs "0 + ..." now is the
constructor _new(), whose input is a string.
Note, however, that the Math::BigInt::FastCalc library method _new() still
creates objects with leading zeros, so until that is fixed, we can't remove
all the "0 + ..." etc. until Math::BigInt::FastCalc has been modified.
2016-07-15 v1.999726 pjacklam
* Re-insert Math::BigFloat->DESTROY, which was accidentally removed in
v1.999725.
Please send us test-reports, your experiences with this and your ideas - we
love to hear about our work!
The Math-BigInt developers <bignum@lists.scsys.co.uk>
......@@ -37,14 +37,91 @@ t/author-bexp-mbf.t
t/author-blog-mbf.t
t/author-blog-mbi.t
t/author-bmod-bdiv-mbi.t
t/author-bnok-mbi.t
t/author-bpi-mbf.t
t/author-btmod-btdiv-mbi.t
t/author-lib-arithmetic-binary-_add.dat
t/author-lib-arithmetic-binary-_add.t
t/author-lib-arithmetic-binary-_div.dat
t/author-lib-arithmetic-binary-_div.t
t/author-lib-arithmetic-binary-_gcd.dat
t/author-lib-arithmetic-binary-_gcd.t
t/author-lib-arithmetic-binary-_log_int-alt.t
t/author-lib-arithmetic-binary-_log_int.t
t/author-lib-arithmetic-binary-_mod.dat
t/author-lib-arithmetic-binary-_mod.t
t/author-lib-arithmetic-binary-_modinv.dat
t/author-lib-arithmetic-binary-_modinv.t
t/author-lib-arithmetic-binary-_mul.dat
t/author-lib-arithmetic-binary-_mul.t
t/author-lib-arithmetic-binary-_pow.t
t/author-lib-arithmetic-binary-_root.dat
t/author-lib-arithmetic-binary-_root.t
t/author-lib-arithmetic-binary-_sub.dat
t/author-lib-arithmetic-binary-_sub.t
t/author-lib-arithmetic-ternary-_lsft.dat
t/author-lib-arithmetic-ternary-_lsft.t
t/author-lib-arithmetic-ternary-_modpow.dat
t/author-lib-arithmetic-ternary-_modpow.t
t/author-lib-arithmetic-ternary-_rsft.dat
t/author-lib-arithmetic-ternary-_rsft.t
t/author-lib-arithmetic-unary-_dec.t
t/author-lib-arithmetic-unary-_fac.dat
t/author-lib-arithmetic-unary-_fac.t
t/author-lib-arithmetic-unary-_inc.t
t/author-lib-arithmetic-unary-_sqrt.dat
t/author-lib-arithmetic-unary-_sqrt.t
t/author-lib-bitwise-_and.dat
t/author-lib-bitwise-_and.t
t/author-lib-bitwise-_or.dat
t/author-lib-bitwise-_or.t
t/author-lib-bitwise-_xor.dat
t/author-lib-bitwise-_xor.t
t/author-lib-boolean-_is_even.t
t/author-lib-boolean-_is_odd.t
t/author-lib-boolean-_is_one.t
t/author-lib-boolean-_is_ten.t
t/author-lib-boolean-_is_two.t
t/author-lib-boolean-_is_zero.t
t/author-lib-comparison-_acmp.t
t/author-lib-constructor-nullary-_one.t
t/author-lib-constructor-nullary-_ten.t
t/author-lib-constructor-nullary-_two.t
t/author-lib-constructor-nullary-_zero.t
t/author-lib-constructor-unary-_copy.t
t/author-lib-constructor-unary-_from_bin.dat
t/author-lib-constructor-unary-_from_bin.t
t/author-lib-constructor-unary-_from_hex.dat
t/author-lib-constructor-unary-_from_hex.t
t/author-lib-constructor-unary-_from_oct.dat
t/author-lib-constructor-unary-_from_oct.t
t/author-lib-constructor-unary-_new.t
t/author-lib-convert-number-_num.t
t/author-lib-convert-string-_as_bin.dat
t/author-lib-convert-string-_as_bin.t
t/author-lib-convert-string-_as_hex.dat
t/author-lib-convert-string-_as_hex.t
t/author-lib-convert-string-_as_oct.dat
t/author-lib-convert-string-_as_oct.t
t/author-lib-convert-string-_str.t
t/author-lib-meta-_check.t
t/author-lib-meta-api_version.t
t/author-lib-meta-config.conf
t/author-lib-property-_alen.t
t/author-lib-property-_digit.t
t/author-lib-property-_len.t
t/author-lib-property-_zeros.t
t/author-lib_load.t
t/author-numify-mbf.t
t/author-numify-mbi.t
t/author-relop-mbi-mbf.t
t/bare_mbf.t
t/bare_mbi.t
t/bare_mif.t
t/bdstr-mbf.t
t/bdstr-mbi.t
t/bestr-mbf.t
t/bestr-mbi.t
t/big_pi_e.t
t/bigfltpm.inc
t/bigfltpm.t
......@@ -54,6 +131,10 @@ t/bigintpm.t
t/bigints.t
t/biglog.t
t/bigroot.t
t/bnstr-mbf.t
t/bnstr-mbi.t
t/bsstr-mbf.t
t/bsstr-mbi.t
t/calling-class-methods.t
t/calling-instance-methods.t
t/calling.t
......@@ -61,6 +142,10 @@ t/config.t
t/const_mbf.t
t/constant.t
t/downgrade.t
t/dparts-mbf.t
t/dparts-mbi.t
t/eparts-mbf.t
t/eparts-mbi.t
t/from_bin-mbf.t
t/from_hex-mbf.t
t/from_oct-mbf.t
......@@ -69,6 +154,7 @@ t/isa.t
t/lib_load.t
t/Math/BigFloat/Subclass.pm
t/Math/BigInt/BareCalc.pm
t/Math/BigInt/Lib/TestUtil.pm
t/Math/BigInt/Scalar.pm
t/Math/BigInt/Subclass.pm
t/mbf_ali.t
......@@ -79,6 +165,8 @@ t/mbimbf.t
t/nan_cmp.t
t/new-mbf.t
t/new_overloaded.t
t/nparts-mbf.t
t/nparts-mbi.t
t/objectify_mbf.t
t/objectify_mbi.t
t/req_mbf0.t
......@@ -90,6 +178,8 @@ t/req_mbfw.t
t/require.t
t/round.t
t/rt-16221.t
t/sparts-mbf.t
t/sparts-mbi.t
t/sub_ali.t
t/sub_mbf.t
t/sub_mbi.t
......
......@@ -4,7 +4,7 @@
"=over 4, Peter John Acklam <pjacklam@online.no>"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150005",
"generated_by" : "ExtUtils::MakeMaker version 7.18, CPAN::Meta::Converter version 2.150005",
"license" : [
"perl_5"
],
......@@ -40,6 +40,6 @@
}
},
"release_status" : "stable",
"version" : "1.999722",
"x_serialization_backend" : "JSON::PP version 2.27300"
"version" : "1.999726",
"x_serialization_backend" : "JSON::PP version 2.27400"
}
......@@ -8,7 +8,7 @@ build_requires:
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150005'
generated_by: 'ExtUtils::MakeMaker version 7.18, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -22,5 +22,5 @@ requires:
Math::Complex: '1.39'
Test::More: '0.9301'
perl: '5.006001'
version: '1.999722'
version: '1.999726'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,7 +4,7 @@ use 5.006001;
use strict;
use warnings;
our $VERSION = '1.999722';
our $VERSION = '1.999726';
$VERSION = eval $VERSION;
package Math::BigInt;
......@@ -25,7 +25,7 @@ sub __emu_band
my ($self,$x,$y,$sx,$sy,@r) = @_;
return $x->bzero(@r) if $y->is_zero() || $x->is_zero();
my $sign = 0; # sign of result
$sign = 1 if $sx == -1 && $sy == -1;
......@@ -75,7 +75,7 @@ sub __emu_band
# if $xx eq "\x00", we can cut $by, otherwise we need to padd $bx
$bx .= $xx x abs($diff);
}
# and the strings together
my $r = $bx & $by;
......@@ -380,7 +380,7 @@ L<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/bignum>
=head1 LICENSE
This program is free software; you may redistribute it and/or modify it under
the same terms as Perl itself.
the same terms as Perl itself.
=head1 AUTHORS
......
#!perl
use strict;
use warnings;
package Math::BigInt::Lib::TestUtil;
our @ISA = qw< Exporter >;
our @EXPORT_OK = qw< randstr >;
# randstr NUM, BASE
#
# Generate a string representing a NUM digit number in base BASE.
sub randstr {
die "randstr: wrong number of input arguments\n"
unless @_ == 2;
my $n = shift;
my $b = shift;
die "randstr: first input argument must be >= 0"
unless $n >= 0;
die "randstr: second input argument must be in the range 2 .. 36\n"
unless 2 <= $b && $b <= 36;
return '' if $n == 0;
my @dig = (0 .. 9, 'a' .. 'z');
my $str = $dig[ 1 + int rand ($b - 1) ];
$str .= $dig[ int rand $b ] for 2 .. $n;
return $str;
}
1;
......@@ -11,15 +11,13 @@ BEGIN {
use strict;
use warnings;
use Test::More tests => 41301;
use Math::BigInt;
use Math::Complex;
use Scalar::Util;
use Test::More;
plan tests => 41301;
my $inf = Math::Complex::Inf();
my $nan = $inf - $inf;
......
This diff is collapsed.
......@@ -11,7 +11,7 @@ BEGIN {
use strict;
use warnings;
use Test::More tests => 19;
use Test::More tests => 9;
use Math::BigFloat;
......@@ -20,89 +20,151 @@ my $pi = {
40 => '3.141592653589793238462643383279502884197',
};
# Called as class method without argument.
subtest "Called as class method without argument.", sub {
plan tests => 5;
my $x;
my $test = '$x = Math::BigFloat -> bpi()';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $x = Math::BigFloat -> bpi();
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {40}, 'Math::BigFloat -> bpi()');
}
is($x, $pi -> {40}, "'$test' gives correct output");
is($x -> {_a}, undef, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
subtest "Called as class method with scalar argument.", sub {
plan tests => 5;
# Called as class method with scalar argument.
my $x;
my $test = '$x = Math::BigFloat -> bpi(16);';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $x = Math::BigFloat -> bpi(16);
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {16}, '$x = Math::BigFloat->bpi(16)');
}
is($x, $pi -> {16}, "'$test' gives correct output");
is($x -> {_a}, 16, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
subtest "Called as class method with class argument.", sub {
plan tests => 5;
# Called as class method with class argument.
my ($n, $x);
my $test = '$n = Math::BigFloat -> new("16"); '
. '$x = Math::BigFloat -> bpi($n);';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $n = Math::BigFloat -> new("16");
my $x = Math::BigFloat -> bpi($n);
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {16},
'$n = Math::BigFloat->new("16"); $x = Math::BigFloat->bpi($n)');
}
is($x, $pi -> {16}, "'$test' gives correct output");
is($x -> {_a}, 16, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
subtest "Called as instance method without argument.", sub {
plan tests => 5;
my $x;
my $test = '$x = Math::BigFloat -> bnan(); $x -> bpi();';
# Called as instance method without argument.
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $x = Math::BigFloat -> bnan();
$x -> bpi();
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {40}, '$x = Math::BigFloat -> bnan(); $x->bpi()');
}
is($x, $pi -> {40}, "'$test' gives correct output");
is($x -> {_a}, undef, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
subtest "Called as instance method with scalar argument.", sub {
plan tests => 5;
my $x;
my $test = '$x = Math::BigFloat -> bnan(); $x -> bpi(16);';
# Called as instance method with scalar argument.
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $x = Math::BigFloat -> bnan();
$x -> bpi(16);
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {16}, '$x = Math::BigFloat -> bnan(); $x->bpi(16)');
}
is($x, $pi -> {16}, "'$test' gives correct output");
is($x -> {_a}, 16, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
subtest "Called as instance method with instance argument.", sub {
plan tests => 5;
# Called as instance method with instance argument.
my ($n, $x);
my $test = '$n = Math::BigFloat -> new("16"); '
. '$x = Math::BigFloat -> bnan(); '
. '$x -> bpi($n);';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $n = Math::BigFloat -> new("16");
my $x = Math::BigFloat -> bnan();
$x -> bpi($n);
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {16}, '$n = Math::BigFloat->new("16"); $x -> bpi($n)');
}
is($x, $pi -> {16}, "'$test' gives correct output");
is($x -> {_a}, 16, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
# Called as function without argument.
subtest "Called as function without argument.", sub {
plan tests => 5;
my $x;
my $test = '$x = Math::BigFloat::bpi();';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $x = Math::BigFloat::bpi();
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {40}, '$x = Math::BigFloat::bpi()');
}
is($x, $pi -> {40}, "'$test' gives correct output");
is($x -> {_a}, undef, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
# Called as function with scalar argument.
subtest "Called as function with scalar argument.", sub {
plan tests => 5;
my $x;
my $test = '$x = Math::BigFloat::bpi(16);';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
{
my $x = Math::BigFloat::bpi(16);
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {16}, '$x = Math::BigFloat::bpi(16)');
}
is($x, $pi -> {16}, "'$test' gives correct output");
is($x -> {_a}, 16, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
};
# Called as function with instance argument.
#
# This is an ambiguous case. The argument list to bpi() is ($n), which is
# assumed to mean $n->bpi(), since we favour the OO-style. So in the test
# The following is an ambiguous case. The argument list to bpi() is ($n), which
# is assumed to mean $n->bpi(), since we favour the OO-style. So in the test
# below, $n is assigned the value of pi with the default number of digits, and
# then $n is assigned to $x.
{
my $n = Math::BigFloat -> new("16");
my $x = Math::BigFloat::bpi($n);
subtest "Called as function with instance argument.", sub {
plan tests => 9;
my ($n, $x);
my $test = '$n = Math::BigFloat -> new("16"); '
. '$x = Math::BigFloat::bpi($n);';
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
isa_ok($x, 'Math::BigFloat');
is($x, $pi -> {40},
'$n = Math::BigFloat->new("16"); $x = Math::BigFloat::bpi($n)');
is($n, $pi -> {40},
'$n = Math::BigFloat->new("16"); $x = Math::BigFloat::bpi($n)');
}
is($x, $pi -> {40}, "'$test' gives correct output");
is($x -> {_a}, undef, "'$test' gives correct accuracy");
is($x -> {_p}, undef, "'$test' gives correct precision");
isa_ok($n, 'Math::BigFloat');
is($n, $pi -> {40}, "'$test' gives correct output");
is($n -> {_a}, undef, "'$test' gives correct accuracy");
is($n -> {_p}, undef, "'$test' gives correct precision");
};
......@@ -11,15 +11,13 @@ BEGIN {
use strict;
use warnings;
use Test::More tests => 41301;;
use Math::BigInt;
use Math::Complex;
use Scalar::Util;
use Test::More;
plan tests => 41301;
my $inf = Math::Complex::Inf();
my $nan = $inf - $inf;
......
This diff is collapsed.
#!perl
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
require Test::More;
Test::More::plan(skip_all =>
'these tests are for testing by the author');
}
}
use strict;
use warnings;
use Test::More tests => 7705;
###############################################################################
# Read and load configuration file and backend library.
my $conffile = 't/author-lib-meta-config.conf';
open CONFFILE, $conffile or die "$conffile: can't open file for reading: $!";
my $confdata = do { local $/ = undef; <CONFFILE>; };
close CONFFILE or die "$conffile: can't close file after reading: $!";
our ($LIB, $REF);
eval $confdata;
die $@ if $@;
eval "require $LIB";
die $@ if $@;
###############################################################################
can_ok($LIB, '_add');
my $scalar_util_ok = eval { require Scalar::Util; };
Scalar::Util -> import('refaddr') if $scalar_util_ok;
diag "Skipping some tests since Scalar::Util is not installed."
unless $scalar_util_ok;
my @data;
# Small numbers (625 tests).
for (my $x = 0; $x <= 24 ; ++ $x) {
for (my $y = 0; $y <= 24 ; ++ $y) {
push @data, [ $x, $y, $x + $y ];
}
}
# 9 + 11, 99 + 101, 999 + 1001, 9999 + 1001, ... (50 tests)
for (my $p = 1; $p <= 50 ; ++ $p) {
my $x = "9" x $p;
my $y = "1" . ("0" x ($p - 1)) . "1";
my $z = "2" . ("0" x $p);
push @data, [ $x, $y, $z ];
}
# 9 + 9, 99 + 99, 999 + 999, 9999 + 9999, ... (50 tests)
for (my $p = 1; $p <= 50 ; ++ $p) {
my $x = "9" x $p;
my $z = "1" . ("9" x ($p - 1)) . "8";
push @data, [ $x, $x, $z ];
}
# Powers of 10 (625 tests).
for (my $p = 0; $p <= 24 ; ++ $p) {
for (my $q = 0; $q <= 24 ; ++ $q) {
my $x = "1" . ("0" x $p);
my $y = "1" . ("0" x $q);
my ($max, $min) = $p > $q ? ($p, $q) : ($q, $p);
my $z = "1" . ("0" x $max);
substr($z, -1 - $min, 1) = substr($z, -1 - $min, 1) + 1;
push @data, [ $x, $y, $z ];
}
}
# Add data in data file.
(my $datafile = $0) =~ s/\.t/.dat/;
open DATAFILE, $datafile or die "$datafile: can't open file for reading: $!";
while (<DATAFILE>) {
s/\s+\z//;
next if /^#/ || ! /\S/;
push @data, [ split /:/ ];