In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/aed13ba6ad26e9b0202672c78a56fd2d9cc4f40a?hp=e7dd2f3ff42856abc2071ce79561be92ca26c61d>

- Log -----------------------------------------------------------------
commit aed13ba6ad26e9b0202672c78a56fd2d9cc4f40a
Author: Jarkko Hietaniemi <[email protected]>
Date:   Tue Sep 2 22:17:50 2014 -0400

    POSIX math: Use 1.0 - erf(x) for erfc().
    
    The newer method was only for x > 0.

M       ext/POSIX/POSIX.xs

commit d6dc3af93837d7218933cafbcfed04c1e6ed4e7e
Author: Jarkko Hietaniemi <[email protected]>
Date:   Tue Sep 2 22:13:05 2014 -0400

    The 'nv' here is not always a NV, so have our own format.
    
    (The added printing of the NV in case of frexp() mess-up caused
     -Wformat warnings.)
    
    (One could argue for renaming the variable to be less confusing.)

M       sv.c
-----------------------------------------------------------------------

Summary of changes:
 ext/POSIX/POSIX.xs | 6 ++----
 sv.c               | 4 +++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 24bd07e..38fdc62 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -502,12 +502,10 @@ static NV my_erf(NV x)
 #  define c99_erf my_erf
 #endif
 
-/* While in theory erfc(x) is just 1-erf(x), thanks to numerical stability
- * things are not so easy. */
 #ifndef c99_erfc
 static NV my_erfc(NV x) {
-  /* Chiani, Dardari & Simon (2003), via Wikipedia */
-  return Perl_exp(-x*x) / 6.0 + Perl_exp(-4.0/3.0 * x*x) / 2.0;
+  /* This is not necessarily numerically stable, but better than nothing. */
+  return 1.0 - c99_erf(x);
 }
 #  define c99_erfc my_erfc
 #endif
diff --git a/sv.c b/sv.c
index 291406e..65aa456 100644
--- a/sv.c
+++ b/sv.c
@@ -10988,8 +10988,10 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char 
*const pat, const STRLEN p
        */
 #if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE > DOUBLESIZE
        long double nv;
+#  define myNVgf PERL_PRIgldbl
 #else
        NV nv;
+#  define myNVgf NVgf
 #endif
        STRLEN have;
        STRLEN need;
@@ -11724,7 +11726,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char 
*const pat, const STRLEN p
                 i = PERL_INT_MIN;
                 (void)Perl_frexp(nv, &i);
                 if (i == PERL_INT_MIN)
-                    Perl_die(aTHX_ "panic: frexp: %"NVgf, nv);
+                    Perl_die(aTHX_ "panic: frexp: %"myNVgf, nv);
                 /* Do not set hexfp earlier since we want to printf
                  * Inf/NaN for Inf/NAN, not their hexfp. */
                 hexfp = isALPHA_FOLD_EQ(c, 'a');

--
Perl5 Master Repository

Reply via email to