From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Rüdiger Sonderfeld" <ruediger@c-plusplus.de>, emacs-devel@gnu.org
Subject: Re: [PATCH] Add support for log2.
Date: Wed, 19 Jun 2013 19:36:14 -0700 [thread overview]
Message-ID: <51C26A9E.7080200@cs.ucla.edu> (raw)
In-Reply-To: <jwv61x9jzoi.fsf-monnier+emacs@gnu.org>
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 <ruediger@c-plusplus.de>
+
+ * configure.ac (log2): Check for this function.
+
2013-06-19 Juanma Barranquero <lekktu@gmail.com>
* .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 <ericb@lsid.hp.com> 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 <ruediger@c-plusplus.de>
+
+ * 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 <lekktu@gmail.com>
* 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);
}
next prev parent reply other threads:[~2013-06-20 2:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 0:03 [PATCH] Add support for log2 Rüdiger Sonderfeld
2013-06-20 2:15 ` Stefan Monnier
2013-06-20 2:36 ` Paul Eggert [this message]
2013-06-20 12:56 ` Rüdiger Sonderfeld
2013-06-20 14:27 ` Paul Eggert
2013-06-20 14:36 ` Rüdiger Sonderfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51C26A9E.7080200@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=ruediger@c-plusplus.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).