develooper Front page | perl.perl5.porters | Postings from April 2015

Re: [perl #124382] [PATCH] Speed up Math::BigFloat -> blog().

Thread Previous
From:
Kent Fredric
Date:
April 24, 2015 13:29
Subject:
Re: [perl #124382] [PATCH] Speed up Math::BigFloat -> blog().
Message ID:
CAATnKFDKkr9-foyphi+_qZAUJfk6yG9cNv-VOO_BU1ViWvtajg@mail.gmail.com
On 25 April 2015 at 01:16, Peter J. Acklam via RT <perlbug-followup@perl.org
> wrote:

> # New Ticket Created by  (Peter J. Acklam)
> # Please include the string:  [perl #124382]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org/Ticket/Display.html?id=124382 >
>
>
> 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.
> >From 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
>
>
>
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
sort of thing lay-folk who are simply using the library would care about,
and so I'm just looking for some kind of assurance the rounding is not
*premature* rounding.

-- 
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About