Commit d9c5e2a0 authored by gregor herrmann's avatar gregor herrmann

Imported Upstream version 1.999701

parent bd15764c
BUGS 100755 → 100644
File mode changed from 100755 to 100644
......@@ -1354,6 +1354,42 @@ The changes are now grouped by distribution.
t/upgrade.inc
* Correct spelling errors.
2015-09-11 v1.999701 pjacklam
* The POD documentation, as well as the comments in the code, said that
$x->bdiv($y) in list context should return quotient $q and remainder $r so
that $x = $q * $y + $r, and that the remainder (modulo) $r should correspond
to Perl's % operator as well as the bmod() method. This has not been the
actual behaviour. This is now fixed.
* 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.
* 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
"Quantifier in {,} bigger than 32766 in regex; marked by ..."
* Intermediate computations in blog() increased the number of digits
significantly in some cases. Now reduce the number of digits by rounding.
However, keep some extra digits for remaining intermediate computations
before the final rounding.
* When $x is a Math::BigFloat, $x -> bceil() and $x -> bint() for -1 < $x < 0
returned -0. Negative zero is never used by Math::Big(Int|Float), and care
has been taken to avoid it, so this bug is surely an oversight.
* Explicitly specify the backend (lib => 'Calc') in t/mbimbf.t for easier
release management of the backend distributions.
* Add "use warnings" to test scripts, since Perl 5.6.2 is required anyway, and
"use warnings" was introduced in Perl 5.6.1.
* Modified test scripts so the difference between the test files in the
Math-BigInt distribution and the backend distributions are as few and as
small as possible. This makes for easier release management.
Please send us test-reports, your experiences with this and your ideas - we love
to hear about our work!
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -4,7 +4,7 @@
"Original code by Mark Biggar, overloaded interface by Ilya Zakharevich., Tels <nospam-abuse@bloodgate.com>"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150005",
"generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005",
"license" : [
"perl_5"
],
......@@ -38,6 +38,6 @@
}
},
"release_status" : "stable",
"version" : "1.9997",
"version" : "1.999701",
"x_serialization_backend" : "JSON::PP version 2.27300"
}
......@@ -8,7 +8,7 @@ build_requires:
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150005'
generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -20,5 +20,5 @@ no_index:
- inc
requires:
perl: '5.006002'
version: '1.9997'
version: '1.999701'
x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
File mode changed from 100755 to 100644
For the list of recent changes see the end of the CHANGES file. Also see
http://perl5.git.perl.org/perl.git/history/HEAD:/dist/Math-BigInt
For the list of recent changes see the end of the CHANGES file.
......@@ -16,7 +16,7 @@ Hash: SHA1
SHA1 f6ef98e8f3f6a4f670d569f279ef5a3c05c16d0c BENCHMARK
SHA1 d681b992c9e027633a59fbd52530805ee4e1621c BUGS
SHA1 378be01aa21fb9c800d26ee6220aeaeb395f75db CHANGES
SHA1 0815a28c08ef29d983d21a6c7683c8c2b0d803e1 CHANGES
SHA1 f27c8bd98e754f96c9825fa6ce9f1244c93bdbe6 CREDITS
SHA1 bc2db74538d3acd53f71b5512a144fe18c253ecd GOALS
SHA1 fe61299e80a1dca48fbaa33f0869e3238ec07c70 HISTORY
......@@ -24,10 +24,10 @@ SHA1 c42565ad26cdf91502bacf19a4f7080e63c51fe2 INSTALL
SHA1 d6a6c30ee6d9ba6b9afab8bbf6a25e1b23c744e0 LICENSE
SHA1 43408348b400ef1d910a18feab394817e343cc86 MANIFEST
SHA1 86df44fbe1ea7a68897113f0e327d0f0c25b91e3 MANIFEST.SKIP
SHA1 7ec6e161448d603d2b089c8673f9f0fd5630bc90 META.json
SHA1 b9755c48a5bcf63579bcab506dc7531dad600441 META.yml
SHA1 d2c249bd0aa356187e6ad4326be5879dd0f83d1c META.json
SHA1 caefe2c8385d8be85408dc56b2c29cede24e3e17 META.yml
SHA1 ae1e2767f1988a537d4a64fc84a07587cbca2ef5 Makefile.PL
SHA1 bcb63898d70e8624bf75b6ed87089c2ab0414b14 NEW
SHA1 4e2191d1724e699862efc5350f480c8e02755112 NEW
SHA1 481f5827752d2100914db1eaeb60bf0bbd13529e README
SHA1 f1500916b488220b707bc10a0388d7dbcfd52e99 TODO
SHA1 c2bbe82659480de8710b9e64a62d47b64dddd2d2 examples/1000.txt
......@@ -41,45 +41,45 @@ SHA1 76efdca3603159e0ae0e18f19fe72a0211a69529 inc/Module/Install/Makefile.pm
SHA1 2e33e87882d60db3913da6284dd5295e5315e18a inc/Module/Install/Metadata.pm
SHA1 c830b819e61bda5eca077c6291293bba61b3b9f2 inc/Module/Install/Win32.pm
SHA1 cb52b9d6f88d512d448a6f35ed0af0d1201a134b inc/Module/Install/WriteAll.pm
SHA1 b47ff4e2795d341a730d67da7f20521579c1deed lib/Math/BigFloat.pm
SHA1 9677dcde0af6adb9ec888da7af2d5eec58798c42 lib/Math/BigInt.pm
SHA1 41199b85065c6435bf562c9ff81a9284ede0ce8b lib/Math/BigInt/Calc.pm
SHA1 0a7d7ef4133281c73e64322e78b8200b5bd4919e lib/Math/BigInt/CalcEmu.pm
SHA1 a2d393f9d265801f8ef022725d03f83b616b2fe1 t/00sig.t
SHA1 32b73052135171974d5c522f0dee665a03dacdbd t/01load.t
SHA1 02ef05af53cb7378452590324bb21dfe61f44069 t/02pod.t
SHA1 929a08bf0508c27e04e1a3a376c869a45751a388 t/03podcov.t
SHA1 bff33aecc126b34d7c2461f8c6ceee4bdabf428d lib/Math/BigFloat.pm
SHA1 981073b6c2b63068f5dee95608b1d14c837af5f7 lib/Math/BigInt.pm
SHA1 5e0a467afb8bfb66938252a2aa055b1cc343d728 lib/Math/BigInt/Calc.pm
SHA1 a5956e02f12e77650bc984f806be1172cab9b278 lib/Math/BigInt/CalcEmu.pm
SHA1 385cc7ed3bf3e6290640b9880445ca9a3dea629e t/00sig.t
SHA1 4463fdcebb8421cc2e63f87d678adb47856bf58c t/01load.t
SHA1 b2ed9206ca5b69ec3b8bbf850bf4b6dfde518e7e t/02pod.t
SHA1 2b9c8202db5c201656fcb5c4e20822365854f3e9 t/03podcov.t
SHA1 63d3ac167c2d98484f521ad9cbddbf306d33d8eb t/Math/BigFloat/Subclass.pm
SHA1 309c0d093884f29111225c2108a33f0e8e028759 t/Math/BigInt/BareCalc.pm
SHA1 62deb0b9e3bf94aaf12745207efa3d858f3b878e t/Math/BigInt/Scalar.pm
SHA1 27c1738a064e7f7bf91c762d411af447847c331c t/Math/BigInt/Subclass.pm
SHA1 a2014803baec5dbef46235f83411f76efa0efea7 t/_e_math.t
SHA1 0e725849a20e80bb1da796a7be40b69a958c8313 t/alias.inc
SHA1 16d36aa915f9d6e86ec3e4f4e05ef26c6129399d t/bare_mbf.t
SHA1 da1d61b785022c275d7d17f62aa6dfcdf1ddadaa t/bare_mbi.t
SHA1 c46706c4d6e75f1be26c938f8de19ca5990c672f t/bare_mbf.t
SHA1 4f40065bfe169022be4742991d4f28da17b65bfd t/bare_mbi.t
SHA1 97fb1db80aeb4ab007e2260d35329e149edf5e05 t/bare_mif.t
SHA1 333a425247b4e276696210a6322b815a0f55f5ab t/big_pi_e.t
SHA1 27da8d84b12593dbc8350efa6b43339a05d344ef t/bigfltpm.inc
SHA1 9537400817c028f2282e3c085796ecbded0ccb66 t/bigfltpm.t
SHA1 d0a7c7c8852762abd7f962d26d72f2f8956f946d t/bigfltpm.inc
SHA1 2feb8161766c7a9427341307ab778f6eccbab21e t/bigfltpm.t
SHA1 b3ceebc429c05bce95347575d28348306dbcfcc8 t/bigintc.t
SHA1 03927c64235f9aa1f1f373bd71328ce7c9afdfb5 t/bigintpm.inc
SHA1 73ac3701a1116b1831c871153c836f618a60f4d7 t/bigintpm.t
SHA1 9fcc5a0c645880be1dc2083dc623de14f6b476d9 t/bigintpm.inc
SHA1 c5f14cee5968dea1b2871f2210a7be1a6a905e8c t/bigintpm.t
SHA1 cb07d195c20eb306088eeacccc2c7475f267446c t/bigints.t
SHA1 4e27fc0056d6455d278c0d38f5fe7f3c9a57fbe8 t/biglog.t
SHA1 da260b6e02b220868fc7b4c0f87569299402fbf7 t/bigroot.t
SHA1 b1aa233c07e7988ef67c9f527c9dc67b46d0a6fc t/bigroot.t
SHA1 2ed03baf88a7d868706605bada7874123f99eded t/calling.t
SHA1 c1f7b6840e772f2b6d4f8dbea4c28aaa675c9b17 t/config.t
SHA1 7c75531325efd55f15ef14e5ca22875d6d53e366 t/const_mbf.t
SHA1 b7891121243029ae078ca952205ce3d037b145d8 t/constant.t
SHA1 d5b1f2d01e954a8b0c41d51f79ec878a305cedf7 t/downgrade.t
SHA1 3c8e85b53a213c3a0379748726c7907ee2c23adc t/inf_nan.t
SHA1 048e4b172645392bac2d5b42a31c01b8ad74f5e2 t/inf_nan.t
SHA1 4ee46eecc74e97f27ef47b208576d179ab01cfb9 t/isa.t
SHA1 95d41431bb5147f2cd97d2f160c1ce220a365142 t/lib_load.t
SHA1 18071d0caf17979c5345baf7b296a1e95d8f9bf1 t/mbf_ali.t
SHA1 79fafec237d6f47d8a176c67418f94c708ed3fec t/mbi_ali.t
SHA1 2b9490eab4d5371b804a39fb16e77c6bd6bbd006 t/mbi_rand.t
SHA1 38d000d99cb2492ab518786e62ab1fae710e0f8d t/mbimbf.inc
SHA1 2709f7d1acdb39aab910d3ba4c88191b28cc3cfc t/mbimbf.t
SHA1 b13701babf6c3952a0b8de3803de838d52a13ddc t/mbimbf.t
SHA1 a8e152beb9c0583cca8ba397ca2952cf456f107c t/nan_cmp.t
SHA1 852bfc6c25fa982e0c48e270277f091732d062e2 t/new_overloaded.t
SHA1 4c28c03a8e373c03a0246548394588855e4173b9 t/req_mbf0.t
......@@ -92,12 +92,12 @@ SHA1 1bbe72733abd2f580f94b6a147672f7671260149 t/require.t
SHA1 ad6cc6fe4bb93ae78db4eb7dcb96c95024b963d2 t/round.t
SHA1 8201ea0035861736224992039bcc01d5bd72b778 t/rt-16221.t
SHA1 9d51def046889bf20c6ac2a278f9b3f5f8e36025 t/sub_ali.t
SHA1 3717645c60b533355006f3966f36c341efea24e7 t/sub_mbf.t
SHA1 3d03b0a0970abc3b27d8b0f20877213c7f3ea87d t/sub_mbi.t
SHA1 7d09d1b2a56c4622536570e6199ce4bab35475ab t/sub_mbf.t
SHA1 211fd2968a2fcbe0384c20c00984f5b8bbbf7688 t/sub_mbi.t
SHA1 a9d994551c5ca127c11f5cdd1d8df1d93972c72c t/sub_mif.t
SHA1 22c563a6879c94ce7c8eb72c645f2e374837c34e t/trap.t
SHA1 73899d40cc0e2f0cdf833ba60cd977da46e626f8 t/upgrade.inc
SHA1 3256f1ecdee8a1aafdcc6142362e815e565e3bff t/upgrade.t
SHA1 6170a40ec68d8821a9d5cb7731cbf35c4c0291b6 t/upgrade.inc
SHA1 85f4acf11c0a9da6c67e21bec6cd3c6e31deea25 t/upgrade.t
SHA1 e9019081ff5c07957e45619010c62a54472d8508 t/upgrade2.t
SHA1 49183118717b8b90e498b6d7b1ac0aa0e4d85894 t/upgradef.t
SHA1 d58003dbb3ffb469dee56b8c93c5a6b3c353ddb7 t/use.t
......@@ -106,15 +106,15 @@ SHA1 4959257dd52935cdfd17b132e11bcdb4e37752e9 t/use_lib2.t
SHA1 29606835c9d63a19075003429b00947b922ef144 t/use_lib3.t
SHA1 a5cc44a7e485828791696b2b27925e0d2855f883 t/use_lib4.t
SHA1 0c5f496ed66b02d0e118763c91862d84e3fb5629 t/use_mbfw.t
SHA1 1d0fbaa1a15cd095c4499a70886a40f1a2a6c7a5 t/with_sub.t
SHA1 d374a32db7274aa29c53f530ec4751509147cc10 t/with_sub.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQEcBAEBAgAGBQJVycQvAAoJEGcmPl2fr166zz8H/jIz/u+YMUUhhcwupf66kBpd
RjxR761QnAYouH/4Z74sPU2yGXGHhBpSC+q5S5j8Fp7Gdytqji8Irg58DXbyn+w8
/G6ki0QChse32C1Qqz+w65+6PYoAnDGao8veOc8zuk+a5ZI5ndIfKj/ZPewPh5Cy
VkD+u4byIVmZJIi0yOHnhIsl/BXBd/Kg44Q3Ogu++y0PdeKv3BaLXHbIUxArYiiL
IiU+ZynWHuPegIpGpaVmV4fi4LpHcwz7Xt9Y8hsDsLlQJW5/jrzPSlcJxvMVNvzL
vMcS1ZdqOJRgkOIFbdDvhtN4p7iM/MNLIqGTx1T0eUyHKYTzWRWGmjRM83TdGV0=
=3FDP
iQEcBAEBAgAGBQJV8xYGAAoJEGcmPl2fr166RiEH/jxwvm/84sby96xXXcrUImDf
EicWgwMfh7r986kcV6yr+ejRm+pQizDoKXt5GbNsLt3xtSjRZHIQazIcJYDxsOMk
m9nRp9jIaESM3kk6pA/Al5OIO+peQ25snQpbn+THHUe07UW9az/aDCdYs878yJXN
K9Gwt16LkVVLXgEKWgzXj988fK7+lu7VvlqUzH3GhTKlG2n4OoELjHHFapG4b6kv
CngwNycCNyoJ+JoG5bfKCMNQfqLKEEeNVLG8cpTB6RFJ81qq1QZB52biVZ89yvOH
N4awcVFWXVtMAKNUYdPD4fetBcGigzdpTtYSdF9YB834q/Ai+xKlvlD6BdrcpaA=
=Ky1R
-----END PGP SIGNATURE-----
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -12,7 +12,7 @@ package Math::BigFloat;
# _a : accuracy
# _p : precision
$VERSION = '1.9997';
$VERSION = '1.999701';
require 5.006002;
require Exporter;
......@@ -1476,6 +1476,7 @@ sub _log_10
{
$twos++; $x->bdiv($two,$scale+4); # keep all digits
}
$x->bround($scale+4);
# $twos > 0 => did mul 2, < 0 => did div 2 (but we never did both)
# So calculate correction factor based on ln(2):
if ($twos != 0)
......@@ -1776,7 +1777,7 @@ sub bmuladd
sub bdiv
{
# (dividend: BFLOAT or num_str, divisor: BFLOAT or num_str) return
# (BFLOAT,BFLOAT) (quo,rem) or BFLOAT (only rem)
# (BFLOAT, BFLOAT) (quo, rem) or BFLOAT (only quo)
# set up parameters
my ($self,$x,$y,$a,$p,$r) = (ref($_[0]),@_);
......@@ -1788,10 +1789,80 @@ sub bdiv
return $x if $x->modify('bdiv');
return $self->_div_inf($x,$y)
if (($x->{sign} !~ /^[+-]$/) || ($y->{sign} !~ /^[+-]$/) || $y->is_zero());
my $wantarray = wantarray; # call only once
# x== 0 # also: or y == 1 or y == -1
# At least one argument is NaN. This is handled the same way as in
# Math::BigInt -> bdiv().
if ($x -> is_nan() || $y -> is_nan()) {
return $wantarray ? ($x -> bnan(), $self -> bnan()) : $x -> bnan();
}
# Divide by zero and modulo zero. This is handled the same way as in
# Math::BigInt -> bdiv(). See the comment in the code for Math::BigInt ->
# bdiv() for further details.
if ($y -> is_zero()) {
my ($quo, $rem);
if ($wantarray) {
$rem = $x -> copy();
}
if ($x -> is_zero()) {
$quo = $x -> bnan();
} else {
$quo = $x -> binf($x -> {sign});
}
return $wantarray ? ($quo, $rem) : $quo;
}
# Numerator (dividend) is +/-inf. This is handled the same way as in
# Math::BigInt -> bdiv(). See the comment in the code for Math::BigInt ->
# bdiv() for further details.
if ($x -> is_inf()) {
my ($quo, $rem);
$rem = $self -> bnan() if $wantarray;
if ($y -> is_inf()) {
$quo = $x -> bnan();
} else {
my $sign = $x -> bcmp(0) == $y -> bcmp(0) ? '+' : '-';
$quo = $x -> binf($sign);
}
return $wantarray ? ($quo, $rem) : $quo;
}
# Denominator (divisor) is +/-inf. This is handled the same way as in
# Math::BigInt -> bdiv(), with one exception: In scalar context,
# Math::BigFloat does true division (although rounded), not floored division
# (F-division), so a finite number divided by +/-inf is always zero. See the
# comment in the code for Math::BigInt -> bdiv() for further details.
if ($y -> is_inf()) {
my ($quo, $rem);
if ($wantarray) {
if ($x -> is_zero() || $x -> bcmp(0) == $y -> bcmp(0)) {
$rem = $x -> copy();
$quo = $x -> bzero();
} else {
$rem = $self -> binf($y -> {sign});
$quo = $x -> bone('-');
}
return ($quo, $rem);
} else {
if ($y -> is_inf()) {
if ($x -> is_nan() || $x -> is_inf()) {
return $x -> bnan();
} else {
return $x -> bzero();
}
}
}
}
# At this point, both the numerator and denominator are finite numbers, and
# the denominator (divisor) is non-zero.
# x == 0?
return wantarray ? ($x,$self->bzero()) : $x if $x->is_zero();
# upgrade ?
......@@ -1805,33 +1876,30 @@ sub bdiv
return $x if $x->is_nan(); # error in _find_round_parameters?
# no rounding at all, so must use fallback
if (scalar @params == 0)
if (scalar @params == 0)
{
# simulate old behaviour
$params[0] = $self->div_scale(); # and round to it as accuracy
$scale = $params[0]+4; # at least four more for proper round
$params[2] = $r; # round mode by caller or undef
$fallback = 1; # to clear a/p afterwards
}
else
{
} else {
# the 4 below is empirical, and there might be cases where it is not
# enough...
$scale = abs($params[0] || $params[1]) + 4; # take whatever is defined
}
my $rem; $rem = $self->bzero() if wantarray;
my $rem;
$rem = $self -> bzero() if wantarray;
$y = $self->new($y) unless $y->isa('Math::BigFloat');
my $lx = $MBI->_len($x->{_m}); my $ly = $MBI->_len($y->{_m});
my $lx = $MBI -> _len($x->{_m}); my $ly = $MBI -> _len($y->{_m});
$scale = $lx if $lx > $scale;
$scale = $ly if $ly > $scale;
my $diff = $ly - $lx;
$scale += $diff if $diff > 0; # if lx << ly, but not if ly << lx!
# already handled inf/NaN/-inf above:
# 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}));
......@@ -1899,7 +1967,7 @@ sub bdiv
{
if ($y_not_one)
{
$x -> bint();
$x -> bfloor();
$rem->bmod($y,@params); # copy already done
}
if ($fallback)
......@@ -1926,34 +1994,54 @@ sub bmod
return $x if $x->modify('bmod');
# handle NaN, inf, -inf
if (($x->{sign} !~ /^[+-]$/) || ($y->{sign} !~ /^[+-]$/))
{
my ($d,$re) = $self->SUPER::_div_inf($x,$y);
$x->{sign} = $re->{sign};
$x->{_e} = $re->{_e};
$x->{_m} = $re->{_m};
return $x->round($a,$p,$r,$y);
# At least one argument is NaN. This is handled the same way as in
# Math::BigInt -> bmod().
if ($x -> is_nan() || $y -> is_nan()) {
return $x -> bnan();
}
if ($y->is_zero())
{
return $x->bnan() if $x->is_zero();
# Modulo zero. This is handled the same way as in Math::BigInt -> bmod().
if ($y -> is_zero()) {
return $x;
}
# Numerator (dividend) is +/-inf. This is handled the same way as in
# Math::BigInt -> bmod().
if ($x -> is_inf()) {
return $x -> bnan();
}
# Denominator (divisor) is +/-inf. This is handled the same way as in
# Math::BigInt -> bmod().
if ($y -> is_inf()) {
if ($x -> is_zero() || $x -> bcmp(0) == $y -> bcmp(0)) {
return $x;
} else {
return $x -> binf($y -> sign());
}
}
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
if ($cmp == 0) { # $x == $y => result 0
return $x -> bzero($a, $p);
}
# only $y of the operands negative?
my $neg = 0; $neg = 1 if $x->{sign} ne $y->{sign};
my $neg = $x->{sign} ne $y->{sign} ? 1 : 0;
$x->{sign} = $y->{sign}; # calc sign first
return $x->round($a,$p,$r) if $cmp < 0 && $neg == 0; # $x < $y => result $x
if ($cmp < 0 && $neg == 0) { # $x < $y => result $x
return $x -> round($a, $p, $r);
}
my $ym = $MBI->_copy($y->{_m});
......@@ -1996,7 +2084,7 @@ sub bmod
$x->{sign} = '+' if $MBI->_is_zero($x->{_m}); # fix sign for -0
$x->bnorm();
if ($neg != 0) # one of them negative => correct in place
if ($neg != 0 && ! $x -> is_zero()) # one of them negative => correct in place
{
my $r = $y - $x;
$x->{_m} = $r->{_m};
......@@ -3440,7 +3528,11 @@ sub bceil
$x->{_m} = $MBI->_rsft($x->{_m},$x->{_e},10); # cut off digits after dot
$x->{_e} = $MBI->_zero(); # trunc/norm
$x->{_es} = '+'; # abs e
$MBI->_inc($x->{_m}) if $x->{sign} eq '+'; # increment if positive
if ($x->{sign} eq '+') {
$MBI->_inc($x->{_m}); # increment if positive
} else {
$x->{sign} = '+' if $MBI->_is_zero($x->{_m}); # avoid -0
}
}
$x->round($a,$p,$r);
}
......@@ -3459,6 +3551,7 @@ sub bint
$x->{_m} = $MBI->_rsft($x->{_m},$x->{_e},10); # cut off digits after dot
$x->{_e} = $MBI->_zero(); # truncate/normalize
$x->{_es} = '+'; # abs e
$x->{sign} = '+' if $MBI->_is_zero($x->{_m}); # avoid -0
}
$x->round($a,$p,$r);
}
......@@ -4027,8 +4120,8 @@ Actual math is done by using the class defined with C<< with => Class; >>
(which defaults to BigInts) to represent the mantissa and exponent.
The sign C</^[+-]$/> is stored separately. The string 'NaN' is used to
represent the result when input arguments are not numbers, as well as
the result of dividing by zero.
represent the result when input arguments are not numbers, and 'inf' and
'-inf' are used to represent positive and negative infinity, respectively.
=head2 mantissa(), exponent() and parts()
......@@ -4208,6 +4301,25 @@ Note: You probably want to use L</accuracy()> instead. With L</accuracy()> you
set the number of digits each result should have, with L</precision()> you
set the place where to round!
=item bdiv()
$q = $x->bdiv($y);
($q, $r) = $x->bdiv($y);
In scalar context, divides $x by $y and returns the result to the given or
default accuracy/precision. In list context, does floored division
(F-division), returning an integer $q and a remainder $r so that $x = $q * $y +
$r. The remainer (modulo) is equal to what is returned by C<$x->bmod($y)>.
=item bmod()
$x->bmod($y);
Returns $x modulo $y. When $x is finite, and $y is finite and non-zero, the
result is identical to the remainder after floored division (F-division). If,
in addition, both $x and $y are integers, the result is identical to the result
from Perl's % operator.
=item bexp()
$x->bexp($accuracy); # calculate e ** X
......
This diff is collapsed.
......@@ -4,7 +4,7 @@ use 5.006002;
use strict;
# use warnings; # do not use warnings for older Perls
our $VERSION = '1.9997';
our $VERSION = '1.999701';
# Package to store unsigned big integers in decimal and do math with them
......
......@@ -5,7 +5,7 @@ use strict;
# use warnings; # do not use warnings for older Perls
use vars qw/$VERSION/;
$VERSION = '1.9997';
$VERSION = '1.999701';
package Math::BigInt;
......
#!/usr/bin/perl -w
#!perl
use strict; # restrict unsafe constructs
use warnings; # enable optional warnings
use Test::More;
......
#!/usr/bin/perl -w
#!perl
use strict; # restrict unsafe constructs
use warnings; # enable optional warnings
use Test::More tests => 2;
......@@ -9,5 +10,17 @@ BEGIN {
use_ok('Math::BigFloat');
};
diag("Testing Math::BigInt $Math::BigInt::VERSION");
diag("==> Perl $], $^X");
my @mods = ('Math::BigInt',
'Math::BigFloat',
'Math::BigInt::Calc',
);
diag("");
diag("Testing with Perl $], $^X");
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("");
#!/usr/bin/perl -w
#!perl
use strict; # restrict unsafe constructs
use warnings; # enable optional warnings
use Test::More;
......
#!/usr/bin/perl -w
#!perl
use strict; # restrict unsafe constructs
use strict; # restrict unsafe constructs
use warnings; # enable optional warnings
use Test::More;
......@@ -9,7 +10,7 @@ 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"
if $@;
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
......@@ -17,19 +18,21 @@ plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
if $@;
plan tests => 2;
my $trustme;
$trustme = {
trustme => [ 'fround', 'objectify' ],
trustme => [ 'fround',
'objectify' ],
};
pod_coverage_ok( 'Math::BigInt', $trustme, "All our Math::BigInts are covered" );
pod_coverage_ok('Math::BigInt', $trustme, "Math::BigInt is covered");
$trustme = {
trustme => [ 'DEBUG', 'isa' ],
trustme => [ 'DEBUG',
'isa' ],
coverage_class => 'Pod::Coverage::CountParents',
};
pod_coverage_ok( 'Math::BigFloat', $trustme, "All our Math::BigFloats are covered" );
pod_coverage_ok('Math::BigFloat', $trustme, "Math::BigFloat is covered");
#!/usr/bin/perl -w
use strict;
use Test::More tests => 2338;
use Test::More tests => 2340;
BEGIN { unshift @INC, 't'; }
......
#!/usr/bin/perl -w
use strict;
use Test::More tests => 3651;
use Test::More tests => 3649;
BEGIN { unshift @INC, 't'; }
......
......@@ -1404,7 +1404,7 @@ NaNmul:-inf:NaN
6:120:720
10:10000:100000
&fdiv-list
0:0:NaN,NaN
0:0:NaN,0
0:1:0,0
9:4:2,1
9:5:1,4
......@@ -1499,13 +1499,13 @@ $div_scale = 40
0:inf:0
0:-inf:0
5:inf:5
5:-inf:5
-5:inf:-5
5:-inf:-inf
-5:inf:inf
-5:-inf:-5
inf:5:0
-inf:5:0
inf:-5:0
-inf:-5:0
inf:5:NaN
-inf:5:NaN
inf:-5:NaN
-inf:-5:NaN
5:5:0
-5:-5:0
inf:inf:NaN
......@@ -1514,14 +1514,12 @@ inf:inf:NaN
inf:-inf:NaN
8:0:8
inf:0:inf
# exceptions to remainder rule
-inf:0:-inf
-8:0:-8
0:0:NaN
0:0:0
abc:abc:NaN
abc:1:abc:NaN
1:abc:NaN
0:0:NaN
0:1:0
1:0:1
0:-1:0
......@@ -1825,6 +1823,7 @@ abc:NaN
-51:-51
-51.2:-51
12.2:13
-0.4:0
&fint
0:0
NaN:NaN
......@@ -1834,3 +1833,4 @@ NaN:NaN
-51:-51
-51.2:-51
12.2:12
-0.4:0
#!/usr/bin/perl -w
use strict;
use Test::More tests => 2338
use Test::More tests => 2340
+ 5; # own tests
......@@ -24,6 +24,11 @@ $c = Math::BigFloat->new('0.008'); my $d = Math::BigFloat->new(3);
my $e = $c->bdiv(Math::BigFloat->new(3),$d);
is ($e,'0.00267'); # '0.008 / 3 => 0.0027');
is (ref($e->{_e}->[0]), ''); # 'Not a BigInt');
SKIP: {
skip("skipping test which is not for this backend", 1)
unless $CL eq 'Math::BigInt::Calc';
is (ref($e->{_e}->[0]), ''); # 'Not a BigInt');
}
require 't/bigfltpm.inc'; # all tests here for sharing
This diff is collapsed.
#!/usr/bin/perl -w
use strict;
use Test::More tests => 3651 + 6;
use Test::More tests => 3649 + 6;
use Math::BigInt lib => 'Calc';
......
File mode changed from 100644 to 100755
#!/usr/bin/perl -w
#!perl
# Test broot function (and bsqrt() function, since it is used by broot()).
......@@ -8,7 +8,9 @@
# But it is better to test the numerical functionality, instead of not testing
# it at all.
use strict;
use strict; # restrict unsafe constructs
use warnings; # enable optional warnings