Commit 0e552f6d authored by Lucas Kanashiro's avatar Lucas Kanashiro

Imported Upstream version 1.999714

parent da58bcba
......@@ -1363,8 +1363,9 @@ The changes are now grouped by distribution.
* Clearer POD documentation for the bdiv() and bmod() methods.
* All input values in the range (-1,1) written as a decimal number, e.g.,
-0.75 and 0.5, now return NaN, not 0.
* All non-integer input values to Math::BigInt gave a NaN, except non-zero
numbers in the range (-1,1) that were written without an exponent, e.g.,
"-0.75" and "0.5". Now also these return a NaN.
* Input values with a large (absolute value) negative exponent, e.g.,
1e-9999999, now return NaN. The former behaviour was to die with the message
......@@ -1509,6 +1510,125 @@ The changes are now grouped by distribution.
* Add 'from_hex' and 'from_bin' to list of methods in the Math::BigInt POD.
2012-12-10 v1.9997_11 pjacklam
This release introduces no changes in the library code, i.e., the .pm files in
the 'lib' directory, but there are a lot of changes in the test files. Since
there are so many changes, I let this be a development release.
* Add 'use strict;' and 'use warnings;' to all test files.
* Reformat code in the test files according to the "perlstyle" manual page.
This makes the code a lot easier to read -- for me, anyway.
* Decrement required version of Perl from v5.6.2 to v5.6.1. All tests pass
when running the test suite with Perl 5.6.1 on Cygwin.
* Replace "use vars ..." with "our ..." in test files.
* Replace "BEGIN { unshift @INC, 't'; }" with "use lib 't';" in test files.
* Use "our $x; $x = ...;" rather than "our $x = ...;" since the latter causes
Perl 5.6.1 to complain about variables only used once.
* Add comment to all tests. Now the tests no longer says just "ok 123", but
rather "ok 123 - $x->blog(2)" etc. This makes it easier to identify failed
tests, especially in the smoke testing reports.
* Fix various flawed tests, e.g., ok($x, 2) was used testing whether $x was 2.
* Use the skip() feature of Test::More for skipping tests.
* Use more descriptive variable names in test files.
* Remove unused variables in test files.
* Move variable declarations to limit their scope in test files.
* Remove trailing whitespace in test files.
* Wrap (most) lines to fit 80 columns in test files.
2015-12-29 v1.999712 pjacklam
* Fix bug in internal function _e_add() and _e_sub() which causes it to return
"-0" in some cases.
* Let new() be used for assignment. Now $x->new(3) assigns 3 to $x.
* Improve code in new() for non-zero scalar integers with no exponent.
* Allow both "inf" and "infinity". Allow a leading sign, and ignore letter
case. This is to be consistent with core Perl.
* Be more consistent about allowed whitespace in input. E.g., "23 " gave 23,
but "inf " gave a NaN.
* Core Perl allows both "0x" and "0X" as hexadecimal prefix, and both "0b" and
"0B" as binary prefix, so we do too. Previously, only 0x and 0b were
allowed.
* Math::BigFloat now has its own from_bin() method which supports binary
floating point numbers, e.g., "0b1.1001p-4". This complements from_hex().
* Math::BigFloat now has its own from_oct() method which supports octal
floating point numbers, e.g., "1.3267p-4". This complements from_hex().
* The Math::BigInt and Math::BigFloat methods from_hex(), from_oct(), and
from_bin() can now be used as instance methods to assign values to the
invocand, e.g, $x->from_oct("10") assigns 8 to $x.
* Update documentation. Perl now uses "Inf", not "inf" to represent infinity.
* When the new() method is called with an undefined argument, the round
parameters are now passed on to bzero(). This applies to both Math::BigInt
and Math::BigFloat.
* Replace "UNIVERSAL::isa($this, $that)" with "$this->isa($that)", and ditto
for "can()", where possible. Not every instance of "UNIVERSAL::Isa()" has
been replaced, though, since the change causes some tests to fail. This must
be looked into.
* Simplify the copy() methods. Always copy accuracy and precision parameters,
even when they are undefined.
* Reformat more of the code in accordancw with the "perlstyle" manual page.
This makes the code a lot easier to read -- for me, anyway.
* Use a more generic regex in t/calling.t, since the exact wording of the
error message depends not on the Perl version, but on the module that does
the version checking.
* Avoid infinite loop in the Math::BigFloat->batan() method. Thanks to DANAJ
(Dana Jacobsen) for the patch. This was not intended to be added before the
next release, but was included in this release by accident.
2015-12-31 v1.999713 pjacklam
* Fix Math::BigInt->new(), which had a faulty handling in the shortcut for
non-zero scalar integers with no non-zero exponent, like "12", "12.000",
"12e3", and "12.000e4". Added tests for this in t/bigintpm.inc.
2016-01-03 v1.999714 pjacklam
* Add code to speed up Math::BigFloat->batan(). Thanks to DANAJ (Dana
Jacobsen) for the patch.
* Re-write Math::BigFloat->batan2() completely, except for the parts related
to the rounding. The old version was sometimes correct, sometimes off by pi,
and sometimes very inaccurate. Also add more tests.
* Make it clearer in Math::BigFloat->bpi() when it is called as a method vs.
as a function.
* The Math::BigFloat->bpi() method can now be used as an instance method to
assign pi to $x, as in $x->bpi().
* Add tests for as_oct().
* Minor simplifications in Math::BigInt->as_oct() as
Math::BigInt::Calc::_as_oct().
Please send us test-reports, your experiences with this and your ideas - we love
to hear about our work!
......
......@@ -31,6 +31,11 @@ t/02pod.t
t/03podcov.t
t/_e_math.t
t/alias.inc
t/author-batan-mbf.t
t/author-batan2-mbf.t
t/author-blog-mbf.t
t/author-blog-mbi.t
t/author-bpi-mbf.t
t/bare_mbf.t
t/bare_mbi.t
t/bare_mif.t
......@@ -43,8 +48,6 @@ t/bigintpm.t
t/bigints.t
t/biglog.t
t/bigroot.t
t/blog-mbf.t
t/blog-mbi.t
t/calling.t
t/config.t
t/const_mbf.t
......
......@@ -35,11 +35,11 @@
"requires" : {
"Math::Complex" : "1.39",
"Test::More" : "0.9301",
"perl" : "5.006002"
"perl" : "5.006001"
}
}
},
"release_status" : "stable",
"version" : "1.999710",
"version" : "1.999714",
"x_serialization_backend" : "JSON::PP version 2.27300"
}
......@@ -21,6 +21,6 @@ no_index:
requires:
Math::Complex: '1.39'
Test::More: '0.9301'
perl: '5.006002'
version: '1.999710'
perl: '5.006001'
version: '1.999714'
x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
#!perl
# We need at least Perl 5.6
require 5.006002;
# We need at least Perl 5.6.1
require 5.006001;
use strict;
# Load the Module::Install bundled in ./inc/
......@@ -14,7 +14,7 @@ name 'Math-BigInt';
all_from 'lib/Math/BigInt.pm';
# Required versions.
requires 'perl' => 5.006002;
requires 'perl' => 5.006001;
requires 'Math::Complex' => 1.39,
test_requires 'Test::More' => 0.9301;
......
This diff is collapsed.
......@@ -72,7 +72,7 @@ $x = (2**3833-1) / $x;
ok (len($x),'1121');
#(2^4751-1)/(268982617*3274778783*629530076753*81630665742097*1507074535068001)
#(2^4751-1)/(268982617*3274778783*629530076753*81630665742097*1507074535068001)
$x = Math::BigInt->new('268982617');
$x = $x * '3274778783' * '629530076753' * '81630665742097' * '1507074535068001';
$x = ((2**4751)-1) / $x;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package Math::BigInt::CalcEmu;
use 5.006002;
use 5.006001;
use strict;
use warnings;
our $VERSION = '1.999710';
our $VERSION = '1.999714';
$VERSION = eval $VERSION;
package Math::BigInt;
......
......@@ -21,6 +21,6 @@ diag("");
diag(sprintf("%12s %s\n", 'Version', 'Module'));
diag(sprintf("%12s %s\n", '-------', '------'));
for my $mod (@mods) {
diag(sprintf("%12s %s\n", $mod -> VERSION, $mod));
diag(sprintf("%12s %s\n", $mod -> VERSION(), $mod));
}
diag("");
......@@ -9,7 +9,8 @@ use Test::More;
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
plan skip_all =>
"Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
......
#!/usr/bin/perl -w
#!perl
# for testing subclassing Math::BigFloat
package Math::BigFloat::Subclass;
require 5.005_02;
require 5.006;
use strict;
use warnings;
use Exporter;
use Math::BigFloat(1.38);
use vars qw($VERSION @ISA $PACKAGE
$accuracy $precision $round_mode $div_scale);
use Math::BigFloat 1.38;
our ($accuracy, $precision, $round_mode, $div_scale);
@ISA = qw(Exporter Math::BigFloat);
our @ISA = qw(Exporter Math::BigFloat);
$VERSION = 0.05;
our $VERSION = "0.06";
use overload; # inherit overload from BigInt
use overload; # inherit overload from BigInt
# Globals
$accuracy = $precision = undef;
$round_mode = 'even';
$div_scale = 40;
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $value = shift;
my $a = $accuracy; $a = $_[0] if defined $_[0];
my $p = $precision; $p = $_[1] if defined $_[1];
# Store the floating point value
my $self = Math::BigFloat->new($value,$a,$p,$round_mode);
bless $self, $class;
$self->{'_custom'} = 1; # make sure this never goes away
return $self;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $value = shift;
my $a = $accuracy; $a = $_[0] if defined $_[0];
my $p = $precision; $p = $_[1] if defined $_[1];
# Store the floating point value
my $self = Math::BigFloat->new($value, $a, $p, $round_mode);
bless $self, $class;
$self->{'_custom'} = 1; # make sure this never goes away
return $self;
}
BEGIN
{
*objectify = \&Math::BigInt::objectify;
# to allow Math::BigFloat::Subclass::bgcd( ... ) style calls
*bgcd = \&Math::BigFloat::bgcd;
*blcm = \&Math::BigFloat::blcm;
}
BEGIN {
*objectify = \&Math::BigInt::objectify;
# to allow Math::BigFloat::Subclass::bgcd( ... ) style calls
*bgcd = \&Math::BigFloat::bgcd;
*blcm = \&Math::BigFloat::blcm;
}
1;
#!perl
package Math::BigInt::BareCalc;
use 5.005;
use strict;
# use warnings; # dont use warnings for older Perls
use warnings;
require Exporter;
use vars qw/@ISA $VERSION/;
@ISA = qw(Exporter);
$VERSION = '0.05';
our @ISA = qw(Exporter);
our $VERSION = '0.06';
sub api_version () { 1; }
# Package to to test Bigint's simulation of Calc
# uses Calc, but only features the strictly necc. methods.
# Uses Calc, but only features the strictly neccessary methods.
use Math::BigInt::Calc '0.51';
BEGIN
{
no strict 'refs';
foreach (qw/
base_len new zero one two ten copy str num add sub mul div mod inc dec
acmp alen len digit zeros
rsft lsft
fac pow gcd log_int sqrt root
is_zero is_one is_odd is_even is_one is_two is_ten check
as_hex as_bin as_oct from_hex from_bin from_oct
modpow modinv
and xor or
/)
BEGIN {
no strict 'refs';
foreach (qw/
base_len new zero one two ten copy str num add sub mul div mod inc dec
acmp alen len digit zeros
rsft lsft
fac pow gcd log_int sqrt root
is_zero is_one is_odd is_even is_one is_two is_ten check
as_hex as_bin as_oct from_hex from_bin from_oct
modpow modinv
and xor or
/)
{
my $name = "Math::BigInt::Calc::_$_";
*{"Math::BigInt::BareCalc::_$_"} = \&$name;
my $name = "Math::BigInt::Calc::_$_";
*{"Math::BigInt::BareCalc::_$_"} = \&$name;
}
print "# BareCalc using Calc v$Math::BigInt::Calc::VERSION\n";
}
print "# BareCalc using Calc v$Math::BigInt::Calc::VERSION\n";
}
# catch and throw away
sub import { }
......
......@@ -4,77 +4,67 @@
package Math::BigInt::Scalar;
use 5.005;
use 5.006;
use strict;
# use warnings; # dont use warnings for older Perls
use warnings;
require Exporter;
use vars qw/@ISA $VERSION/;
@ISA = qw(Exporter);
our @ISA = qw(Exporter);
$VERSION = '0.13';
our $VERSION = '0.13';
sub api_version() { 1; }
##############################################################################
# global constants, flags and accessory
# constants for easier life
my $nan = 'NaN';
##############################################################################
# create objects from various representations
sub _new
{
# create scalar ref from string
my $d = $_[1];
my $x = $d; # make copy
\$x;
}
sub _from_hex
{
# not used
}
sub _from_oct
{
# not used
}
sub _from_bin
{
# not used
}
sub _zero
{
my $x = 0; \$x;
}
sub _one
{
my $x = 1; \$x;
}
sub _two
{
my $x = 2; \$x;
}
sub _ten
{
my $x = 10; \$x;
}
sub _copy
{
my $x = $_[1];
my $z = $$x;
\$z;
}
sub _new {
# create scalar ref from string
my $d = $_[1];
my $x = $d; # make copy
\$x;
}
sub _from_hex {
# not used
}
sub _from_oct {
# not used
}
sub _from_bin {
# not used
}
sub _zero {
my $x = 0; \$x;
}
sub _one {
my $x = 1; \$x;
}
sub _two {
my $x = 2; \$x;
}
sub _ten {
my $x = 10; \$x;
}
sub _copy {
my $x = $_[1];
my $z = $$x;
\$z;
}
# catch and throw away
sub import { }
......@@ -82,247 +72,212 @@ sub import { }
##############################################################################
# convert back to string and number
sub _str
{
# make string
"${$_[1]}";
}
sub _num
{
# make a number
0+${$_[1]};
}
sub _zeros
{
my $x = $_[1];
$x =~ /\d(0*)$/;
length($1 || '');
}
sub _rsft
{
# not used
}
sub _lsft
{
# not used
}
sub _mod
{
# not used
}
sub _gcd
{
# not used
}
sub _sqrt
{
# not used
}
sub _root
{
# not used
}
sub _fac
{
# not used
}
sub _modinv
{
# not used
}
sub _modpow
{
# not used
}
sub _log_int
{
# not used
}
sub _as_hex
{
sprintf("0x%x",${$_[1]});
}
sub _as_bin
{
sprintf("0b%b",${$_[1]});
}
sub _as_oct
{
sprintf("0%o",${$_[1]});
}
sub _str {
# make string
"${$_[1]}";
}
sub _num {
# make a number
0+${$_[1]};
}
sub _zeros {
my $x = $_[1];
$x =~ /\d(0*)$/;
length($1 || '');
}
sub _rsft {
# not used
}
sub _lsft {
# not used
}
sub _mod {
# not used
}
sub _gcd {
# not used
}
sub _sqrt {
# not used
}
sub _root {
# not used
}
sub _fac {
# not used
}
sub _modinv {
# not used
}
sub _modpow {
# not used
}
sub _log_int {
# not used
}
sub _as_hex {
sprintf("0x%x", ${$_[1]});
}
sub _as_bin {
sprintf("0b%b", ${$_[1]});
}
sub _as_oct {
sprintf("0%o", ${$_[1]});
}
##############################################################################
# actual math code
sub _add
{
my ($c,$x,$y) = @_;
$$x += $$y;
return $x;
}
sub _sub
{
my ($c,$x,$y) = @_;
$$x -= $$y;
return $x;
}
sub _mul
{
my ($c,$x,$y) = @_;
$$x *= $$y;
return $x;
}
sub _div
{
my ($c,$x,$y) = @_;
my $u = int($$x / $$y); my $r = $$x % $$y; $$x = $u;
return ($x,\$r) if wantarray;
return $x;
}
sub _pow
{
my ($c,$x,$y) = @_;
my $u = $$x ** $$y; $$x = $u;
return $x;
}
sub _and
{
my ($c,$x,$y) = @_;
my $u = int($$x) & int($$y); $$x = $u;
return $x;
}
sub _xor
{
my ($c,$x,$y) = @_;
my $u = int($$x) ^ int($$y); $$x = $u;
return $x;
}
sub _or
{
my ($c,$x,$y) = @_;
my $u = int($$x) | int($$y); $$x = $u;