[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Support of log10?
From: |
Eli Zaretskii |
Subject: |
Re: Support of log10? |
Date: |
Thu, 24 Jun 2021 09:28:26 +0300 |
> From: Peng Yu <pengyu.ut@gmail.com>
> Date: Wed, 23 Jun 2021 20:30:48 -0500
> Cc: bug-gawk <bug-gawk@gnu.org>
>
> > | 16.3 Arbitrary-Precision Arithmetic Features in gawk
> >
> > | By default, gawk uses the double-precision
> > | floating-point values [...] However, if it was
> > | compiled to do so, and the -M command-line
> > | option is supplied, gawk uses the GNU MPFR and
> > | GNU MP (GMP) libraries
>
> The above sentence is not clear. What is the difference between MPFR
> and GMP? Why both of them need to be used?
Because the MPFR library relies on GMP for some of its functionality.
> The drawback of -M is that it can be many times slow?
Yes.
> In this sense float log10 function may still be useful?
Who said you will always get exactly 3 if you have log10?
And why are exact powers of 10 even interesting enough to justify yet
another built-in function? After all, if you are only interested in
exact powers of 10, you don't need a math function at all, you simply
count the zero digits in the string representation of the number.
> time gawk -e 'function log10(x) { return log(x)/log(10); } {
> for(i=1;i<=1000000;++i) log10(10^$1) }' <<< 3
>
> real 0m0.180s
> user 0m0.176s
> sys 0m0.002s
> time gawk -M -e 'function log10(x) { return log(x)/log(10); } {
> for(i=1;i<=1000000;++i) log10(10^$1) }' <<< 3
>
> real 0m2.842s
> user 0m2.838s
> sys 0m0.003s
Is it reasonable to need to calculate log10 1 million times? In what
real-life situation of using Gawk does this happen?