New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] Speed up Math::BigFloat -> blog(). #14671
Comments
From @pjacklamSpeed up Math::BigFloat -> blog(). - Intermediate computations in blog() increases the number of digits - This patch fixes CPAN RT #43924. |
From @pjacklam0001-Speed-up-Math-BigFloat-blog.patchFrom a6be9fcc4d8599540a1ec04fd04f8d9d0672cad0 Mon Sep 17 00:00:00 2001
From: Peter John Acklam <pjacklam@online.no>
Date: Fri, 24 Apr 2015 15:13:33 +0200
Subject: [PATCH] Speed up Math::BigFloat -> blog().
- Intermediate computations in blog() increases the number of digits
significantly in some cases. Reduce the number of digits by rounding.
However, keep some extra digits for remaining intermediate computations
before the final rounding.
- This patch fixes CPAN RT #43924.
---
dist/Math-BigInt/lib/Math/BigFloat.pm | 1 +
1 file changed, 1 insertion(+)
diff --git a/dist/Math-BigInt/lib/Math/BigFloat.pm b/dist/Math-BigInt/lib/Math/BigFloat.pm
index 1c31496..3c51914 100644
--- a/dist/Math-BigInt/lib/Math/BigFloat.pm
+++ b/dist/Math-BigInt/lib/Math/BigFloat.pm
@@ -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)
--
2.1.4
|
From @kentfredricOn 25 April 2015 at 01:16, Peter J. Acklam via RT <perlbug-followup@perl.org
Q) Does this affect the overall precision of the floating point math? I am ignorant of the internals, but that sort of concern seems to be the -- *KENTNL* - https://metacpan.org/author/KENTNL |
The RT System itself - Status changed from 'new' to 'open' |
From @pjacklam
The code already rounds to $scale+4 digits, in other cases which involve more intermediate computation, so using four extra digits in this case, should not make things any worse than they already are. I am working on a test program to check blog() more throughly. |
From @tonycozOn Fri Apr 24 06:16:29 2015, pjacklam wrote:
Thanks, applied to blead as 0d2463e. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
@tonycoz - Status changed from 'resolved' to 'pending release' |
From @khwilliamsonThank you for submitting this report. You have helped make Perl better. Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0 |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#124382 (status was 'resolved')
Searchable as RT124382$
The text was updated successfully, but these errors were encountered: