diff options
| author | Paul Eggert | 2013-06-20 07:15:42 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-06-20 07:15:42 -0700 |
| commit | 89561f72e587677618afa2fd6962704e841e39e8 (patch) | |
| tree | 9b790c6b916c853df24a72eebd505c38501ccec6 | |
| parent | 47199123698df3a14acb016c3869075b2d6012d5 (diff) | |
| download | emacs-89561f72e587677618afa2fd6962704e841e39e8.tar.gz emacs-89561f72e587677618afa2fd6962704e841e39e8.zip | |
Add log2 support and make log10 obsolete for consistency.
* configure.ac (log2): Check for this function.
* doc/lispref/numbers.texi (Math Functions): Remove obsolete function log10.
* lisp/subr.el (log10): Move here from C code, and declare as obsolete.
All uses of (log10 X) replaced with (log X 10).
* src/floatfns.c (Flog) [HAVE_LOG2]: Use log2 if available and if the
base is 2; this is more accurate.
(Flog10): Move to Lisp (marked obsolete there).
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/lispref/numbers.texi | 5 | ||||
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/allout.el | 4 | ||||
| -rw-r--r-- | lisp/calc/calc.el | 2 | ||||
| -rw-r--r-- | lisp/subr.el | 5 | ||||
| -rw-r--r-- | lisp/textmodes/rst.el | 4 | ||||
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/floatfns.c | 25 |
12 files changed, 44 insertions, 26 deletions
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-06-20 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> | ||
| 2 | |||
| 3 | * configure.ac (log2): Check for this function. | ||
| 4 | |||
| 1 | 2013-06-19 Juanma Barranquero <lekktu@gmail.com> | 5 | 2013-06-19 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 6 | ||
| 3 | * .bzrignore: Add GNU GLOBAL files. | 7 | * .bzrignore: Add GNU GLOBAL files. |
diff --git a/configure.ac b/configure.ac index a16a52d43ad..6e5c888b437 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -3235,7 +3235,7 @@ gai_strerror mkstemp getline getdelim sync \ | |||
| 3235 | difftime posix_memalign \ | 3235 | difftime posix_memalign \ |
| 3236 | getpwent endpwent getgrent endgrent \ | 3236 | getpwent endpwent getgrent endgrent \ |
| 3237 | touchlock \ | 3237 | touchlock \ |
| 3238 | cfmakeraw cfsetspeed copysign __executable_start) | 3238 | cfmakeraw cfsetspeed copysign __executable_start log2) |
| 3239 | 3239 | ||
| 3240 | ## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines | 3240 | ## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines |
| 3241 | ## has a broken `rint' in some library versions including math library | 3241 | ## has a broken `rint' in some library versions including math library |
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 65fc76d15f5..c00d3392908 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-06-20 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * numbers.texi (Math Functions): Remove obsolete function log10. | ||
| 4 | |||
| 1 | 2013-06-19 Stefan Monnier <monnier@iro.umontreal.ca> | 5 | 2013-06-19 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 6 | ||
| 3 | * modes.texi (Mode Line Data, Properties in Mode): Advertise `keymap' | 7 | * modes.texi (Mode Line Data, Properties in Mode): Advertise `keymap' |
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index eeebac6bf72..2b6f31b670b 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi | |||
| @@ -1156,11 +1156,6 @@ This function returns the logarithm of @var{arg}, with base | |||
| 1156 | returns a NaN. | 1156 | returns a NaN. |
| 1157 | @end defun | 1157 | @end defun |
| 1158 | 1158 | ||
| 1159 | @defun log10 arg | ||
| 1160 | This function returns the logarithm of @var{arg}, with base 10: | ||
| 1161 | @code{(log10 @var{x})} @equiv{} @code{(log @var{x} 10)}. | ||
| 1162 | @end defun | ||
| 1163 | |||
| 1164 | @defun expt x y | 1159 | @defun expt x y |
| 1165 | This function returns @var{x} raised to power @var{y}. If both | 1160 | This function returns @var{x} raised to power @var{y}. If both |
| 1166 | arguments are integers and @var{y} is positive, the result is an | 1161 | arguments are integers and @var{y} is positive, the result is an |
| @@ -469,6 +469,7 @@ file using `set-file-extended-attributes'. | |||
| 469 | ** New macro with-eval-after-load. Like eval-after-load, but better behaved. | 469 | ** New macro with-eval-after-load. Like eval-after-load, but better behaved. |
| 470 | 470 | ||
| 471 | ** Obsoleted functions: | 471 | ** Obsoleted functions: |
| 472 | *** `log10' | ||
| 472 | *** `dont-compile' | 473 | *** `dont-compile' |
| 473 | *** `lisp-complete-symbol' | 474 | *** `lisp-complete-symbol' |
| 474 | *** `field-complete' | 475 | *** `field-complete' |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0a9187435f1..1bfad0f9179 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-06-20 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * subr.el (log10): Move here from C code, and declare as obsolete. | ||
| 4 | All uses of (log10 X) replaced with (log X 10). | ||
| 5 | |||
| 1 | 2013-06-20 Juanma Barranquero <lekktu@gmail.com> | 6 | 2013-06-20 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 7 | ||
| 3 | * emacs-lisp/tabulated-list.el (tabulated-list-format): Fix typo. | 8 | * emacs-lisp/tabulated-list.el (tabulated-list-format): Fix typo. |
diff --git a/lisp/allout.el b/lisp/allout.el index 1e4134b3ccf..a0d61eb6f35 100644 --- a/lisp/allout.el +++ b/lisp/allout.el | |||
| @@ -5342,7 +5342,7 @@ Optional arg CONTEXT indicates interior levels to include." | |||
| 5342 | (cons (make-string | 5342 | (cons (make-string |
| 5343 | (1+ (truncate (if (zerop (car flat-index)) | 5343 | (1+ (truncate (if (zerop (car flat-index)) |
| 5344 | 1 | 5344 | 1 |
| 5345 | (log10 (car flat-index))))) | 5345 | (log (car flat-index) 10)))) |
| 5346 | ? ) | 5346 | ? ) |
| 5347 | result))) | 5347 | result))) |
| 5348 | (setq flat-index (cdr flat-index))) | 5348 | (setq flat-index (cdr flat-index))) |
| @@ -5382,7 +5382,7 @@ Optional arg CONTEXT indicates interior levels to include." | |||
| 5382 | (cons (make-string | 5382 | (cons (make-string |
| 5383 | (1+ (truncate (if (zerop (car flat-index)) | 5383 | (1+ (truncate (if (zerop (car flat-index)) |
| 5384 | 1 | 5384 | 1 |
| 5385 | (log10 (car flat-index))))) | 5385 | (log (car flat-index) 10)))) |
| 5386 | ? ) | 5386 | ? ) |
| 5387 | result))) | 5387 | result))) |
| 5388 | (setq flat-index (cdr flat-index))) | 5388 | (setq flat-index (cdr flat-index))) |
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index bd5c9089bcc..8a17ad7ce30 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el | |||
| @@ -2485,7 +2485,7 @@ the United States." | |||
| 2485 | 2485 | ||
| 2486 | 2486 | ||
| 2487 | (defconst math-bignum-digit-length | 2487 | (defconst math-bignum-digit-length |
| 2488 | (truncate (/ (log10 (/ most-positive-fixnum 2)) 2)) | 2488 | (truncate (/ (log (/ most-positive-fixnum 2) 10) 2)) |
| 2489 | "The length of a \"digit\" in Calc bignums. | 2489 | "The length of a \"digit\" in Calc bignums. |
| 2490 | If a big integer is of the form (bigpos N0 N1 ...), this is the | 2490 | If a big integer is of the form (bigpos N0 N1 ...), this is the |
| 2491 | length of the allowable Emacs integers N0, N1,... | 2491 | length of the allowable Emacs integers N0, N1,... |
diff --git a/lisp/subr.el b/lisp/subr.el index eba99b839e6..b8a62023805 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1206,6 +1206,11 @@ is converted into a string by expressing it in decimal." | |||
| 1206 | (declare (obsolete make-hash-table "22.1")) | 1206 | (declare (obsolete make-hash-table "22.1")) |
| 1207 | (make-hash-table :test (or test 'eql))) | 1207 | (make-hash-table :test (or test 'eql))) |
| 1208 | 1208 | ||
| 1209 | (defun log10 (x) | ||
| 1210 | "Return (log X 10), the log base 10 of X." | ||
| 1211 | (declare (obsolete log "24.4")) | ||
| 1212 | (log x 10)) | ||
| 1213 | |||
| 1209 | ;; These are used by VM and some old programs | 1214 | ;; These are used by VM and some old programs |
| 1210 | (defalias 'focus-frame 'ignore "") | 1215 | (defalias 'focus-frame 'ignore "") |
| 1211 | (make-obsolete 'focus-frame "it does nothing." "22.1") | 1216 | (make-obsolete 'focus-frame "it does nothing." "22.1") |
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index 01981175e1d..a841ec39314 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el | |||
| @@ -2419,8 +2419,8 @@ level to align." | |||
| 2419 | ;; for the numbers. | 2419 | ;; for the numbers. |
| 2420 | (if (cdr node) | 2420 | (if (cdr node) |
| 2421 | (setq fmt (format "%%-%dd" | 2421 | (setq fmt (format "%%-%dd" |
| 2422 | (1+ (floor (log10 (length | 2422 | (1+ (floor (log (length (cdr node)) |
| 2423 | (cdr node)))))))))) | 2423 | 10)))))))) |
| 2424 | 2424 | ||
| 2425 | (dolist (child (cdr node)) | 2425 | (dolist (child (cdr node)) |
| 2426 | (rst-toc-insert-node child | 2426 | (rst-toc-insert-node child |
diff --git a/src/ChangeLog b/src/ChangeLog index 68138e46b6b..c503da29732 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-06-20 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * floatfns.c (Flog10): Move to Lisp (marked obsolete there). | ||
| 4 | |||
| 5 | 2013-06-20 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> | ||
| 6 | |||
| 7 | * floatfns.c (Flog) [HAVE_LOG2]: Use log2 if available and if the | ||
| 8 | base is 2; this is more accurate. | ||
| 9 | |||
| 1 | 2013-06-19 Juanma Barranquero <lekktu@gmail.com> | 10 | 2013-06-19 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 11 | ||
| 3 | * sound.c (string_default): Move to !WINDOWSNT section. | 12 | * sound.c (string_default): Move to !WINDOWSNT section. |
diff --git a/src/floatfns.c b/src/floatfns.c index dd6d3dfe582..f3d0936f888 100644 --- a/src/floatfns.c +++ b/src/floatfns.c | |||
| @@ -25,7 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 25 | /* C89 requires only the following math.h functions, and Emacs omits | 25 | /* C89 requires only the following math.h functions, and Emacs omits |
| 26 | the starred functions since we haven't found a use for them: | 26 | the starred functions since we haven't found a use for them: |
| 27 | acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod, | 27 | acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod, |
| 28 | frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh. | 28 | frexp, ldexp, log, log10 [via (log X 10)], *modf, pow, sin, *sinh, |
| 29 | sqrt, tan, *tanh. | ||
| 29 | 30 | ||
| 30 | C99 and C11 require the following math.h functions in addition to | 31 | C99 and C11 require the following math.h functions in addition to |
| 31 | the C89 functions. Of these, Emacs currently exports only the | 32 | the C89 functions. Of these, Emacs currently exports only the |
| @@ -33,10 +34,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 33 | acosh, atanh, cbrt, *copysign, erf, erfc, exp2, expm1, fdim, fma, | 34 | acosh, atanh, cbrt, *copysign, erf, erfc, exp2, expm1, fdim, fma, |
| 34 | fmax, fmin, fpclassify, hypot, ilogb, isfinite, isgreater, | 35 | fmax, fmin, fpclassify, hypot, ilogb, isfinite, isgreater, |
| 35 | isgreaterequal, isinf, isless, islessequal, islessgreater, *isnan, | 36 | isgreaterequal, isinf, isless, islessequal, islessgreater, *isnan, |
| 36 | isnormal, isunordered, lgamma, log1p, log2, *logb (approximately), | 37 | isnormal, isunordered, lgamma, log1p, *log2 [via (log X 2)], *logb |
| 37 | lrint/llrint, lround/llround, nan, nearbyint, nextafter, | 38 | (approximately), lrint/llrint, lround/llround, nan, nearbyint, |
| 38 | nexttoward, remainder, remquo, *rint, round, scalbln, scalbn, | 39 | nextafter, nexttoward, remainder, remquo, *rint, round, scalbln, |
| 39 | signbit, tgamma, trunc. | 40 | scalbn, signbit, tgamma, trunc. |
| 40 | */ | 41 | */ |
| 41 | 42 | ||
| 42 | #include <config.h> | 43 | #include <config.h> |
| @@ -252,21 +253,16 @@ If the optional argument BASE is given, return log ARG using that base. */) | |||
| 252 | 253 | ||
| 253 | if (b == 10.0) | 254 | if (b == 10.0) |
| 254 | d = log10 (d); | 255 | d = log10 (d); |
| 256 | #if HAVE_LOG2 | ||
| 257 | else if (b == 2.0) | ||
| 258 | d = log2 (d); | ||
| 259 | #endif | ||
| 255 | else | 260 | else |
| 256 | d = log (d) / log (b); | 261 | d = log (d) / log (b); |
| 257 | } | 262 | } |
| 258 | return make_float (d); | 263 | return make_float (d); |
| 259 | } | 264 | } |
| 260 | 265 | ||
| 261 | DEFUN ("log10", Flog10, Slog10, 1, 1, 0, | ||
| 262 | doc: /* Return the logarithm base 10 of ARG. */) | ||
| 263 | (Lisp_Object arg) | ||
| 264 | { | ||
| 265 | double d = extract_float (arg); | ||
| 266 | d = log10 (d); | ||
| 267 | return make_float (d); | ||
| 268 | } | ||
| 269 | |||
| 270 | DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, | 266 | DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, |
| 271 | doc: /* Return the square root of ARG. */) | 267 | doc: /* Return the square root of ARG. */) |
| 272 | (Lisp_Object arg) | 268 | (Lisp_Object arg) |
| @@ -564,7 +560,6 @@ syms_of_floatfns (void) | |||
| 564 | defsubr (&Sexp); | 560 | defsubr (&Sexp); |
| 565 | defsubr (&Sexpt); | 561 | defsubr (&Sexpt); |
| 566 | defsubr (&Slog); | 562 | defsubr (&Slog); |
| 567 | defsubr (&Slog10); | ||
| 568 | defsubr (&Ssqrt); | 563 | defsubr (&Ssqrt); |
| 569 | 564 | ||
| 570 | defsubr (&Sabs); | 565 | defsubr (&Sabs); |