Commit 504c2c7b authored by Lucas Kanashiro's avatar Lucas Kanashiro

Imported Upstream version 1.999715

parent 0e552f6d
...@@ -1102,7 +1102,8 @@ Math::BigInt: ...@@ -1102,7 +1102,8 @@ Math::BigInt:
* fix bug #21446 - Docs/code inconsistency for bnorm() method * fix bug #21446 - Docs/code inconsistency for bnorm() method
* fix bug #21964 - A patch to include a rounding mode of 'common' * fix bug #21964 - A patch to include a rounding mode of 'common'
* fix bug #21445 - Documentation error for exponent() method * fix bug #21445 - Documentation error for exponent() method
* fix bug perl #41050 - NaN returned when raising integer value to negative power * fix bug perl #41050 - NaN returned when raising integer value to negative
power
* add from_hex(), from_oct(), and from_bin() * add from_hex(), from_oct(), and from_bin()
* add as_oct() * add as_oct()
...@@ -1629,6 +1630,19 @@ there are so many changes, I let this be a development release. ...@@ -1629,6 +1630,19 @@ there are so many changes, I let this be a development release.
* Minor simplifications in Math::BigInt->as_oct() as * Minor simplifications in Math::BigInt->as_oct() as
Math::BigInt::Calc::_as_oct(). Math::BigInt::Calc::_as_oct().
2016-01-05 v1.999715 pjacklam
* Fix Math::BigFloat->bexp() based on patch by DANAJ (Dana Jacobsen).
* Add Math::BigFloat->bexp() tests to "t/biglog.t" and new file
"t/author-bexp-mbf.t".
* Fix flawed test in test_bpow. It used ok($x, $y) rather than is($x, $y).
* Add better descriptions (test names) to a few tests.
* Wrap long line in the CHANGES file.
Please send us test-reports, your experiences with this and your ideas - we love Please send us test-reports, your experiences with this and your ideas - we love
to hear about our work! to hear about our work!
......
...@@ -33,6 +33,7 @@ t/_e_math.t ...@@ -33,6 +33,7 @@ t/_e_math.t
t/alias.inc t/alias.inc
t/author-batan-mbf.t t/author-batan-mbf.t
t/author-batan2-mbf.t t/author-batan2-mbf.t
t/author-bexp-mbf.t
t/author-blog-mbf.t t/author-blog-mbf.t
t/author-blog-mbi.t t/author-blog-mbi.t
t/author-bpi-mbf.t t/author-bpi-mbf.t
......
...@@ -40,6 +40,6 @@ ...@@ -40,6 +40,6 @@
} }
}, },
"release_status" : "stable", "release_status" : "stable",
"version" : "1.999714", "version" : "1.999715",
"x_serialization_backend" : "JSON::PP version 2.27300" "x_serialization_backend" : "JSON::PP version 2.27300"
} }
...@@ -22,5 +22,5 @@ requires: ...@@ -22,5 +22,5 @@ requires:
Math::Complex: '1.39' Math::Complex: '1.39'
Test::More: '0.9301' Test::More: '0.9301'
perl: '5.006001' perl: '5.006001'
version: '1.999714' version: '1.999715'
x_serialization_backend: 'CPAN::Meta::YAML version 0.016' x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
...@@ -16,15 +16,15 @@ Hash: SHA1 ...@@ -16,15 +16,15 @@ Hash: SHA1
SHA1 f6ef98e8f3f6a4f670d569f279ef5a3c05c16d0c BENCHMARK SHA1 f6ef98e8f3f6a4f670d569f279ef5a3c05c16d0c BENCHMARK
SHA1 d681b992c9e027633a59fbd52530805ee4e1621c BUGS SHA1 d681b992c9e027633a59fbd52530805ee4e1621c BUGS
SHA1 7f02bf52dd5014c40220109acde082f7d3877569 CHANGES SHA1 56305ead4acbfba4cd2ad75bd300348880d7e84e CHANGES
SHA1 f27c8bd98e754f96c9825fa6ce9f1244c93bdbe6 CREDITS SHA1 f27c8bd98e754f96c9825fa6ce9f1244c93bdbe6 CREDITS
SHA1 bc2db74538d3acd53f71b5512a144fe18c253ecd GOALS SHA1 bc2db74538d3acd53f71b5512a144fe18c253ecd GOALS
SHA1 fe61299e80a1dca48fbaa33f0869e3238ec07c70 HISTORY SHA1 fe61299e80a1dca48fbaa33f0869e3238ec07c70 HISTORY
SHA1 d6a6c30ee6d9ba6b9afab8bbf6a25e1b23c744e0 LICENSE SHA1 d6a6c30ee6d9ba6b9afab8bbf6a25e1b23c744e0 LICENSE
SHA1 4cc885e89752af0c176c60087a729e4f6019664f MANIFEST SHA1 528e7714188e2467c521b4a42cdef9af57ae84a2 MANIFEST
SHA1 86df44fbe1ea7a68897113f0e327d0f0c25b91e3 MANIFEST.SKIP SHA1 86df44fbe1ea7a68897113f0e327d0f0c25b91e3 MANIFEST.SKIP
SHA1 6e3cd50ff6334d058416509496c09253979c216e META.json SHA1 24b4f9de847ad57e5279ed66a02d18ae39658f24 META.json
SHA1 eed445f2f09c6b064a9cd7d85c9e718e47b78952 META.yml SHA1 68078ebf5d437da92e7ea68bf2dff17f9d52ffcc META.yml
SHA1 2b614d9027b35fcc411dbb248c0ab3338ee3430f Makefile.PL SHA1 2b614d9027b35fcc411dbb248c0ab3338ee3430f Makefile.PL
SHA1 4e2191d1724e699862efc5350f480c8e02755112 NEW SHA1 4e2191d1724e699862efc5350f480c8e02755112 NEW
SHA1 813c62e6d3edd18b7b634765ecbd75b2cd6389a0 README SHA1 813c62e6d3edd18b7b634765ecbd75b2cd6389a0 README
...@@ -40,10 +40,10 @@ SHA1 76efdca3603159e0ae0e18f19fe72a0211a69529 inc/Module/Install/Makefile.pm ...@@ -40,10 +40,10 @@ SHA1 76efdca3603159e0ae0e18f19fe72a0211a69529 inc/Module/Install/Makefile.pm
SHA1 2e33e87882d60db3913da6284dd5295e5315e18a inc/Module/Install/Metadata.pm SHA1 2e33e87882d60db3913da6284dd5295e5315e18a inc/Module/Install/Metadata.pm
SHA1 c830b819e61bda5eca077c6291293bba61b3b9f2 inc/Module/Install/Win32.pm SHA1 c830b819e61bda5eca077c6291293bba61b3b9f2 inc/Module/Install/Win32.pm
SHA1 cb52b9d6f88d512d448a6f35ed0af0d1201a134b inc/Module/Install/WriteAll.pm SHA1 cb52b9d6f88d512d448a6f35ed0af0d1201a134b inc/Module/Install/WriteAll.pm
SHA1 a480d78f014a2361361378fcff9bb201fe02893f lib/Math/BigFloat.pm SHA1 6c40c07f32ee38ddb3e900f10f4751fa6dacf035 lib/Math/BigFloat.pm
SHA1 5e82fd620f613d34b03bf82600959b75dbe5d0d1 lib/Math/BigInt.pm SHA1 27a66c373f3c0a5ae198afe788b559cd361fa1a7 lib/Math/BigInt.pm
SHA1 1aa06acce95bbdb4f227e043de75327bfe04a58d lib/Math/BigInt/Calc.pm SHA1 0807737d74be329e4251a2abd4914587a5c34e2a lib/Math/BigInt/Calc.pm
SHA1 808e961862eae9b9cf77672c96264d945f7bb0d2 lib/Math/BigInt/CalcEmu.pm SHA1 9e774f501bd57f96b27d18cd4342708738e46ee4 lib/Math/BigInt/CalcEmu.pm
SHA1 385cc7ed3bf3e6290640b9880445ca9a3dea629e t/00sig.t SHA1 385cc7ed3bf3e6290640b9880445ca9a3dea629e t/00sig.t
SHA1 551efa40942b38f7f521b5a511d08f29ef7b4a1b t/01load.t SHA1 551efa40942b38f7f521b5a511d08f29ef7b4a1b t/01load.t
SHA1 b2ed9206ca5b69ec3b8bbf850bf4b6dfde518e7e t/02pod.t SHA1 b2ed9206ca5b69ec3b8bbf850bf4b6dfde518e7e t/02pod.t
...@@ -56,6 +56,7 @@ SHA1 6d11459530fb13a9e3c490cc3cb9040f9b78cdb4 t/_e_math.t ...@@ -56,6 +56,7 @@ SHA1 6d11459530fb13a9e3c490cc3cb9040f9b78cdb4 t/_e_math.t
SHA1 0d67c764487923bd2427c7ac20778308bea548d6 t/alias.inc SHA1 0d67c764487923bd2427c7ac20778308bea548d6 t/alias.inc
SHA1 bcf4632983c6b52fcc7d694a60899576a4ec8fbe t/author-batan-mbf.t SHA1 bcf4632983c6b52fcc7d694a60899576a4ec8fbe t/author-batan-mbf.t
SHA1 d6dd884fbd6cc3f8967dc5426e0c2c6f81f21e5b t/author-batan2-mbf.t SHA1 d6dd884fbd6cc3f8967dc5426e0c2c6f81f21e5b t/author-batan2-mbf.t
SHA1 4c66c320be87292fb55149be8dd8545fb3a13d2c t/author-bexp-mbf.t
SHA1 843080d13c065d28a7186d1fc46a982b84b9f753 t/author-blog-mbf.t SHA1 843080d13c065d28a7186d1fc46a982b84b9f753 t/author-blog-mbf.t
SHA1 a904010b47c4ad7e9f117d4a3ff80a3dbee493c0 t/author-blog-mbi.t SHA1 a904010b47c4ad7e9f117d4a3ff80a3dbee493c0 t/author-blog-mbi.t
SHA1 1b60e86b66129b2fd448e004a5f59451b875aa97 t/author-bpi-mbf.t SHA1 1b60e86b66129b2fd448e004a5f59451b875aa97 t/author-bpi-mbf.t
...@@ -69,9 +70,9 @@ SHA1 6b9090d78157541f539b2bfbd8bf25a9066857a7 t/bigintc.t ...@@ -69,9 +70,9 @@ SHA1 6b9090d78157541f539b2bfbd8bf25a9066857a7 t/bigintc.t
SHA1 8196aa86f15868a91cde4ca849b1035cfee856dd t/bigintpm.inc SHA1 8196aa86f15868a91cde4ca849b1035cfee856dd t/bigintpm.inc
SHA1 e69dbf31bd6a8ca43ae6a6746b53a1b8bec9c9e7 t/bigintpm.t SHA1 e69dbf31bd6a8ca43ae6a6746b53a1b8bec9c9e7 t/bigintpm.t
SHA1 9aac2eda0e723298c8f9ddadffde39a8c16fb171 t/bigints.t SHA1 9aac2eda0e723298c8f9ddadffde39a8c16fb171 t/bigints.t
SHA1 fb6ac25ad97faab42321aaa8d1e4ff55931f8031 t/biglog.t SHA1 89e6c8b733ae772b7096a9edab565c4034686951 t/biglog.t
SHA1 1ff35e339b269f853106accb80c5d7ecc46e10e4 t/bigroot.t SHA1 1ff35e339b269f853106accb80c5d7ecc46e10e4 t/bigroot.t
SHA1 6b6caa720150a2ee04737c2302dc48d8e3a1bf33 t/calling.t SHA1 7edc2e0f720f997fe98fb33b117e64736646051b t/calling.t
SHA1 c403d1c64ae6c3b803fc8cd0d10a1df15219057f t/config.t SHA1 c403d1c64ae6c3b803fc8cd0d10a1df15219057f t/config.t
SHA1 af01ecfb6f43bb518c67185eb063c196e2dbdc48 t/const_mbf.t SHA1 af01ecfb6f43bb518c67185eb063c196e2dbdc48 t/const_mbf.t
SHA1 17eb15c35392945a5b3ed2b711f7d166fca294de t/constant.t SHA1 17eb15c35392945a5b3ed2b711f7d166fca294de t/constant.t
...@@ -117,11 +118,11 @@ SHA1 3c213bb219bcbfbfba0f0455ab69e5895e25dfe2 t/with_sub.t ...@@ -117,11 +118,11 @@ SHA1 3c213bb219bcbfbfba0f0455ab69e5895e25dfe2 t/with_sub.t
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1 Version: GnuPG v1
iQEcBAEBAgAGBQJWiQ4vAAoJEGcmPl2fr166lvUH/0Ou2yDeO+MBrKuO1kSPgpLo iQEcBAEBAgAGBQJWi97UAAoJEGcmPl2fr166IhMH/Rpijmbg4Ewdr/QhbyWlR6yM
T8FrUUZPTid258tuE6OftOCvM6nGaK6NZuSyyBKpL2SzgQFbo24TSk0nCkhVhqxP fiyDkXj/zl+pz7QbDtk5mOnZq/e4Vg5ue/VilaYt80Ocr+TFL6dtSM1PVIg2r5ac
ZciEbwg/Kx7Xw5kOXdYvP/1x9bIlQuQbYvO734SblKCpOquPqH9OKnb4GqIgpjYV 0nDqnN+r10L9lwFX593gJxFv8QPlCgu2sSiEqT9XWAQ+KfIC/EwX3NvTetSQB8Fk
UqkWRHVKywv+xdrtM+1Wkl5SsGZ1cv6NSmKH3d47KELHCxpcLd1XMrDPSPyBjBih +lEP4sMDeGRDEYH/B37SK4gicOX76aggTEuEz3XQba8TXSoHUnwSR8XbdyzfrgpZ
gJe08Wa4pSBoPHrr7fWaTQmy+f8xdiWbwTbPqKw5VYPa2ORuzDKdaVj+cW8vyeG9 lDDZVGB87CglhoqYtxs9S9Vw3lNXIF7LcU9cC/lReZpmjKedq3E8P90LPIJe2r9r
N98+iJ9sIGE7Wq7Sge314XurmugT1nxpjFny5Y3CrGAwaOb4OwpjNdTC0cOhGGE= k4lrmriHo5r7dU/THeAh1mTbzfkFhdxyU+WyW9m3Nd2DgDfAcMWGRW/RlxqEnz4=
=1gPA =agTs
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----
...@@ -16,7 +16,7 @@ use 5.006001; ...@@ -16,7 +16,7 @@ use 5.006001;
use strict; use strict;
use warnings; use warnings;
our $VERSION = '1.999714'; our $VERSION = '1.999715';
$VERSION = eval $VERSION; $VERSION = eval $VERSION;
require Exporter; require Exporter;
...@@ -1264,8 +1264,22 @@ sub bexp ...@@ -1264,8 +1264,22 @@ sub bexp
# $x contains now an estimate of e, with some surplus digits, so we can round # $x contains now an estimate of e, with some surplus digits, so we can round
if (!$x_org->is_one()) if (!$x_org->is_one())
{ {
# raise $x to the wanted power and round it in one step: # Reduce size of fractional part, followup with integer power of two.
$x->bpow($x_org, @params); my $lshift = 0;
while ($lshift < 30 && $x_org->bacmp(2 << $lshift) > 0)
{
$lshift++;
}
# Raise $x to the wanted power and round it.
if ($lshift == 0)
{
$x->bpow($x_org, @params);
}
else
{
my($mul, $rescale) = (1 << $lshift, $scale+1+$lshift);
$x->bpow(scalar $x_org->bdiv($mul,$rescale),$rescale)->bpow($mul, @params);
}
} }
else else
{ {
...@@ -2546,6 +2560,8 @@ sub _pow ...@@ -2546,6 +2560,8 @@ sub _pow
my ($limit,$v,$u,$below,$factor,$next,$over); my ($limit,$v,$u,$below,$factor,$next,$over);
$u = $x->copy()->blog(undef,$scale)->bmul($y); $u = $x->copy()->blog(undef,$scale)->bmul($y);
my $do_invert = ($u->{sign} eq '-');
$u->bneg() if $do_invert;
$v = $self->bone(); # 1 $v = $self->bone(); # 1
$factor = $self->new(2); # 2 $factor = $self->new(2); # 2
$x->bone(); # first term: 1 $x->bone(); # first term: 1
...@@ -2570,6 +2586,12 @@ sub _pow ...@@ -2570,6 +2586,12 @@ sub _pow
#$steps++; #$steps++;
} }
if ($do_invert)
{
my $x_copy = $x->copy;
$x->bone->bdiv($x_copy, $scale);
}
# shortcut to not run through _find_round_parameters again # shortcut to not run through _find_round_parameters again
if (defined $params[0]) if (defined $params[0])
......
...@@ -19,7 +19,7 @@ use 5.006001; ...@@ -19,7 +19,7 @@ use 5.006001;
use strict; use strict;
use warnings; use warnings;
our $VERSION = '1.999714'; our $VERSION = '1.999715';
$VERSION = eval $VERSION; $VERSION = eval $VERSION;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
......
...@@ -4,7 +4,7 @@ use 5.006001; ...@@ -4,7 +4,7 @@ use 5.006001;
use strict; use strict;
use warnings; use warnings;
our $VERSION = '1.999714'; our $VERSION = '1.999715';
$VERSION = eval $VERSION; $VERSION = eval $VERSION;
# Package to store unsigned big integers in decimal and do math with them # Package to store unsigned big integers in decimal and do math with them
......
...@@ -4,7 +4,7 @@ use 5.006001; ...@@ -4,7 +4,7 @@ use 5.006001;
use strict; use strict;
use warnings; use warnings;
our $VERSION = '1.999714'; our $VERSION = '1.999715';
$VERSION = eval $VERSION; $VERSION = eval $VERSION;
package Math::BigInt; package Math::BigInt;
......
This diff is collapsed.
...@@ -14,32 +14,32 @@ ...@@ -14,32 +14,32 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 70; use Test::More tests => 73;
use Math::BigFloat; use Math::BigFloat;
use Math::BigInt; use Math::BigInt;
my $class = "Math::BigInt"; my $class = "Math::BigInt";
############################################################################# ###############################################################################
# test $n->blog() in Math::BigInt (broken until 1.80) # test $n->blog() in Math::BigInt (broken until 1.80)
is($class->new(2)->blog(), '0', "$class->new(2)->blog()"); is($class->new(2)->blog(), '0', "$class->new(2)->blog()");
is($class->new(288)->blog(), '5', "$class->new(288)->blog()"); is($class->new(288)->blog(), '5', "$class->new(288)->blog()");
is($class->new(2000)->blog(), '7', "$class->new(2000)->blog()"); is($class->new(2000)->blog(), '7', "$class->new(2000)->blog()");
############################################################################# ###############################################################################
# test $n->bexp() in Math::BigInt # test $n->bexp() in Math::BigInt
is($class->new(1)->bexp(), '2', "$class->new(1)->bexp()"); is($class->new(1)->bexp(), '2', "$class->new(1)->bexp()");
is($class->new(2)->bexp(), '7', "$class->new(2)->bexp()"); is($class->new(2)->bexp(), '7', "$class->new(2)->bexp()");
is($class->new(3)->bexp(), '20', "$class->new(3)->bexp()"); is($class->new(3)->bexp(), '20', "$class->new(3)->bexp()");
############################################################################# ###############################################################################
############################################################################# ###############################################################################
# Math::BigFloat tests # Math::BigFloat tests
############################################################################# ###############################################################################
# test $n->blog(undef, N) where N > 67 (broken until 1.82) # test $n->blog(undef, N) where N > 67 (broken until 1.82)
$class = "Math::BigFloat"; $class = "Math::BigFloat";
...@@ -65,7 +65,7 @@ is($class->new(21)->blog(undef, 71), ...@@ -65,7 +65,7 @@ is($class->new(21)->blog(undef, 71),
'3.0445224377234229965005979803657054342845752874046106401940844835750742', '3.0445224377234229965005979803657054342845752874046106401940844835750742',
"$class->new(21)->blog(undef, 71)"); "$class->new(21)->blog(undef, 71)");
############################################################################# ###############################################################################
# These tests are now really fast, since they collapse to blog(10), basically # These tests are now really fast, since they collapse to blog(10), basically
# Don't attempt to run them with older versions. You are warned. # Don't attempt to run them with older versions. You are warned.
...@@ -148,7 +148,7 @@ is($class->new("10")->bpow("0.6", 10), "3.981071706", ...@@ -148,7 +148,7 @@ is($class->new("10")->bpow("0.6", 10), "3.981071706",
# blog should handle bigint input # blog should handle bigint input
is(Math::BigFloat::blog(Math::BigInt->new(100), 10), 2, "blog(100)"); is(Math::BigFloat::blog(Math::BigInt->new(100), 10), 2, "blog(100)");
############################################################################# ###############################################################################
# some integer results # some integer results
is($class->new(2)->bpow(32)->blog(2), "32", "2 ** 32"); is($class->new(2)->bpow(32)->blog(2), "32", "2 ** 32");
is($class->new(3)->bpow(32)->blog(3), "32", "3 ** 32"); is($class->new(3)->bpow(32)->blog(3), "32", "3 ** 32");
...@@ -162,32 +162,44 @@ $x = Math::BigInt->new('777') ** 777; ...@@ -162,32 +162,44 @@ $x = Math::BigInt->new('777') ** 777;
$base = Math::BigInt->new('777'); $base = Math::BigInt->new('777');
is($x->copy()->blog($base), 777, 'blog(777**777, 777)'); is($x->copy()->blog($base), 777, 'blog(777**777, 777)');
############################################################################# ###############################################################################
# test for bug in bsqrt() not taking negative _e into account # test for bug in bsqrt() not taking negative _e into account
test_bpow ('200', '0.5', 10, '14.14213562'); test_bpow('200', '0.5', 10, '14.14213562');
test_bpow ('20', '0.5', 10, '4.472135955'); test_bpow('20', '0.5', 10, '4.472135955');
test_bpow ('2', '0.5', 10, '1.414213562'); test_bpow('2', '0.5', 10, '1.414213562');
test_bpow ('0.2', '0.5', 10, '0.4472135955'); test_bpow('0.2', '0.5', 10, '0.4472135955');
test_bpow ('0.02', '0.5', 10, '0.1414213562'); test_bpow('0.02', '0.5', 10, '0.1414213562');
test_bpow ('0.49', '0.5', undef, '0.7'); test_bpow('0.49', '0.5', undef, '0.7');
test_bpow ('0.49', '0.5', 10, '0.7000000000'); test_bpow('0.49', '0.5', 10, '0.7000000000');
test_bpow ('0.002', '0.5', 10, '0.04472135955'); test_bpow('0.002', '0.5', 10, '0.04472135955');
test_bpow ('0.0002', '0.5', 10, '0.01414213562'); test_bpow('0.0002', '0.5', 10, '0.01414213562');
test_bpow ('0.0049', '0.5', undef, '0.07'); test_bpow('0.0049', '0.5', undef, '0.07');
test_bpow ('0.0049', '0.5', 10, '0.07000000000'); test_bpow('0.0049', '0.5', 10, '0.07000000000');
test_bpow ('0.000002', '0.5', 10, '0.001414213562'); test_bpow('0.000002', '0.5', 10, '0.001414213562');
test_bpow ('0.021', '0.5', 10, '0.1449137675'); test_bpow('0.021', '0.5', 10, '0.1449137675');
test_bpow ('1.2', '0.5', 10, '1.095445115'); test_bpow('1.2', '0.5', 10, '1.095445115');
test_bpow ('1.23', '0.5', 10, '1.109053651'); test_bpow('1.23', '0.5', 10, '1.109053651');
test_bpow ('12.3', '0.5', 10, '3.507135583'); test_bpow('12.3', '0.5', 10, '3.507135583');
test_bpow ('9.9', '0.5', 10, '3.146426545'); test_bpow('9.9', '0.5', 10, '3.146426545');
test_bpow ('9.86902225', '0.5', 10, '3.141500000'); test_bpow('9.86902225', '0.5', 10, '3.141500000');
test_bpow ('9.86902225', '0.5', undef, '3.1415'); test_bpow('9.86902225', '0.5', undef, '3.1415');
test_bpow ('0.2', '0.41', 10, '0.5169187652'); ###############################################################################
# other tests for bpow()
#############################################################################
test_bpow('0.2', '0.41', 10, '0.5169187652');
is($class->new("0.01")->bpow("28.4", 40)->bsstr(),
'1584893192461113485202101373391507013269e-96',
qq|$class->new("0.01")->bpow("28.4", 40)->bsstr()|);
# The following test takes too long.
#is($class->new("2")->bpow("-1034.5", 40)->bsstr(),
# '3841222690408590466868250378242558090957e-351',
# qq|$class->new("2")->bpow("-1034.5", 40)|);
###############################################################################
# test bexp() with cached results # test bexp() with cached results
is($class->new(1)->bexp(), '2.718281828459045235360287471352662497757', is($class->new(1)->bexp(), '2.718281828459045235360287471352662497757',
...@@ -198,25 +210,35 @@ is($class->new(2)->bexp(40), $class->new(1)->bexp(45)->bpow(2, 40), ...@@ -198,25 +210,35 @@ is($class->new(2)->bexp(40), $class->new(1)->bexp(45)->bpow(2, 40),
is($class->new("12.5")->bexp(61), $class->new(1)->bexp(65)->bpow(12.5, 61), is($class->new("12.5")->bexp(61), $class->new(1)->bexp(65)->bpow(12.5, 61),
'bexp(12.5)'); 'bexp(12.5)');
############################################################################# ###############################################################################
# test bexp() with big values (non-cached) # test bexp() with big values (non-cached)
is($class->new(1)->bexp(100), is($class->new(1)->bexp(100),
'2.7182818284590452353602874713526624977572470936999' '2.7182818284590452353602874713526624977572470936999'
. '59574966967627724076630353547594571382178525166427', . '59574966967627724076630353547594571382178525166427',
'bexp(100)'); qq|$class->new(1)->bexp(100)|);
is($class->new("12.5")->bexp(91), $class->new(1)->bexp(95)->bpow(12.5, 91), is($class->new("12.5")->bexp(91), $class->new(1)->bexp(95)->bpow(12.5, 91),
'bexp(12.5) to 91 digits'); qq|$class->new("12.5")->bexp(91)|);
is($class->new("-118.5")->bexp(20)->bsstr(),
'34364014567198602057e-71',
qq|$class->new("-118.5")->bexp(20)->bsstr()|);
is($class->new("-394.84010945715266885")->bexp(20)->bsstr(),
'33351796227864913873e-191',
qq|$class->new("-118.5")->bexp(20)->bsstr()|);
# all done # all done
1; 1;
############################################################################# ###############################################################################
sub test_bpow
{
my ($x, $y, $scale, $result) = @_;
print "# Tried: $x->bpow($y, $scale);\n" sub test_bpow {
unless ok($class->new($x)->bpow($y, $scale), $result); my ($x, $y, $scale, $result) = @_;
} is($class->new($x)->bpow($y, $scale), $result,
qq|$class->new($x)->bpow($y, |
. (defined($scale) ? $scale : 'undef')
. qq|)|);
}
...@@ -6,7 +6,7 @@ use strict; ...@@ -6,7 +6,7 @@ use strict;
use warnings; use warnings;
use lib 't'; use lib 't';
my $VERSION = '1.999714'; # adjust manually to match latest release my $VERSION = '1.999715'; # adjust manually to match latest release
$VERSION = eval $VERSION; $VERSION = eval $VERSION;
use Test::More tests => 161; use Test::More tests => 161;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment