emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add support for log2.


From: Paul Eggert
Subject: Re: [PATCH] Add support for log2.
Date: Wed, 19 Jun 2013 19:36:14 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

Elisp already has a syntax for log2 (X), namely (log X 2),
so how about the following more-conservative change?
This avoids adding the "log2" function to the Emacs namespace,
thus no need for a NEWS entry, doc change, etc.

(I know the same argument applies to log10, but
that horse left the barn long ago.)

=== modified file 'ChangeLog'
--- ChangeLog   2013-06-19 20:10:57 +0000
+++ ChangeLog   2013-06-20 02:32:16 +0000
@@ -1,3 +1,7 @@
+2013-06-20  Rüdiger Sonderfeld <address@hidden>
+
+       * configure.ac (log2): Check for this function.
+
 2013-06-19  Juanma Barranquero  <address@hidden>
 
        * .bzrignore: Add GNU GLOBAL files.

=== modified file 'configure.ac'
--- configure.ac        2013-06-17 06:03:19 +0000
+++ configure.ac        2013-06-20 02:31:58 +0000
@@ -3235,7 +3235,7 @@
 difftime posix_memalign \
 getpwent endpwent getgrent endgrent \
 touchlock \
-cfmakeraw cfsetspeed copysign __executable_start)
+cfmakeraw cfsetspeed copysign __executable_start log2)
 
 ## Eric Backus <address@hidden> says, HP-UX 9.x on HP 700 machines
 ## has a broken `rint' in some library versions including math library

=== modified file 'src/ChangeLog'
--- src/ChangeLog       2013-06-19 20:10:57 +0000
+++ src/ChangeLog       2013-06-20 02:31:58 +0000
@@ -1,3 +1,8 @@
+2013-06-20  Rüdiger Sonderfeld <address@hidden>
+
+       * floatfns.c (Flog) [HAVE_LOG2]: Use log2 if available and if the
+       base is 2; in practice it's more accurate.
+
 2013-06-19  Juanma Barranquero  <address@hidden>
 
        * sound.c (string_default): Move to !WINDOWSNT section.

=== modified file 'src/floatfns.c'
--- src/floatfns.c      2013-06-20 01:19:43 +0000
+++ src/floatfns.c      2013-06-20 02:31:58 +0000
@@ -33,10 +33,10 @@
    acosh, atanh, cbrt, *copysign, erf, erfc, exp2, expm1, fdim, fma,
    fmax, fmin, fpclassify, hypot, ilogb, isfinite, isgreater,
    isgreaterequal, isinf, isless, islessequal, islessgreater, *isnan,
-   isnormal, isunordered, lgamma, log1p, log2, *logb (approximately),
-   lrint/llrint, lround/llround, nan, nearbyint, nextafter,
-   nexttoward, remainder, remquo, *rint, round, scalbln, scalbn,
-   signbit, tgamma, trunc.
+   isnormal, isunordered, lgamma, log1p, *log2 [via (log X 2)], *logb
+   (approximately), lrint/llrint, lround/llround, nan, nearbyint,
+   nextafter, nexttoward, remainder, remquo, *rint, round, scalbln,
+   scalbn, signbit, tgamma, trunc.
  */
 
 #include <config.h>
@@ -252,6 +252,10 @@
 
       if (b == 10.0)
        d = log10 (d);
+#if HAVE_LOG2
+      else if (b == 2.0)
+       d = log2 (d);
+#endif
       else
        d = log (d) / log (b);
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]