diff options
| author | Paul Eggert | 2015-10-20 18:16:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-10-20 18:22:48 -0700 |
| commit | e9af822ac3ddf9644aa4a68e56b0580e133449b2 (patch) | |
| tree | 55b2ae836adac54903d43ee77e2730a0e2ac86bd | |
| parent | 513fe25a501b41f9f2aac67f73c8e8730aed81b0 (diff) | |
| download | emacs-e9af822ac3ddf9644aa4a68e56b0580e133449b2.tar.gz emacs-e9af822ac3ddf9644aa4a68e56b0580e133449b2.zip | |
(/ N) now returns the reciprocal of N
This is more compatible with Common Lisp and XEmacs (Bug#21690). See:
http://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01053.html
* lisp/color.el (color-hue-to-rgb, color-hsl-to-rgb)
(color-xyz-to-srgb, color-xyz-to-lab):
* lisp/emacs-lisp/cl-extra.el (cl-float-limits):
* lisp/net/shr-color.el (shr-color-hue-to-rgb)
(shr-color-hsl-to-rgb-fractions):
Exploit the change to simplify the code a bit.
* lisp/emacs-lisp/bytecomp.el (byte-compile-quo):
Don’t complain about single-argument calls to ‘/’.
* src/data.c (arith_driver, float_arith_driver):
Implement the change.
| -rw-r--r-- | doc/lispref/numbers.texi | 17 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/color.el | 18 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cl-extra.el | 2 | ||||
| -rw-r--r-- | lisp/net/shr-color.el | 6 | ||||
| -rw-r--r-- | src/data.c | 11 |
7 files changed, 41 insertions, 23 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 3c70d2f0a06..54c8d3e5988 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi | |||
| @@ -642,10 +642,11 @@ product. When given no arguments, @code{*} returns 1. | |||
| 642 | @end example | 642 | @end example |
| 643 | @end defun | 643 | @end defun |
| 644 | 644 | ||
| 645 | @defun / dividend divisor &rest divisors | 645 | @defun / number &rest divisors |
| 646 | This function divides @var{dividend} by @var{divisor} and returns the | 646 | With one or more @var{divisors}, this function divides @var{number} |
| 647 | quotient. If there are additional arguments @var{divisors}, then it | 647 | by each divisor in @var{divisors} in turn, and returns the quotient. |
| 648 | divides @var{dividend} by each divisor in turn. Each argument may be a | 648 | With no @var{divisors}, this function returns 1/@var{number}, i.e., |
| 649 | the multiplicative inverse of @var{number}. Each argument may be a | ||
| 649 | number or a marker. | 650 | number or a marker. |
| 650 | 651 | ||
| 651 | If all the arguments are integers, the result is an integer, obtained | 652 | If all the arguments are integers, the result is an integer, obtained |
| @@ -673,6 +674,14 @@ by rounding the quotient towards zero after each division. | |||
| 673 | @result{} 2.5 | 674 | @result{} 2.5 |
| 674 | @end group | 675 | @end group |
| 675 | @group | 676 | @group |
| 677 | (/ 4.0) | ||
| 678 | @result{} 0.25 | ||
| 679 | @end group | ||
| 680 | @group | ||
| 681 | (/ 4) | ||
| 682 | @result{} 0 | ||
| 683 | @end group | ||
| 684 | @group | ||
| 676 | (/ 25 3 2) | 685 | (/ 25 3 2) |
| 677 | @result{} 4 | 686 | @result{} 4 |
| 678 | @end group | 687 | @end group |
| @@ -1008,6 +1008,12 @@ dynamically. | |||
| 1008 | dynamically. Any third-party code that changes these templates should | 1008 | dynamically. Any third-party code that changes these templates should |
| 1009 | be updated accordingly. | 1009 | be updated accordingly. |
| 1010 | 1010 | ||
| 1011 | +++ | ||
| 1012 | ** ‘(/ N)’ is now equivalent to ‘(/ 1 N)’ rather than to ‘(/ N 1)’. | ||
| 1013 | The new behavior is compatible with Common Lisp and with XEmacs. | ||
| 1014 | This change does not affect Lisp code intended to be portable to | ||
| 1015 | Emacs 24.2 and earlier, which did not support unary ‘/’. | ||
| 1016 | |||
| 1011 | 1017 | ||
| 1012 | * Lisp Changes in Emacs 25.1 | 1018 | * Lisp Changes in Emacs 25.1 |
| 1013 | 1019 | ||
diff --git a/lisp/color.el b/lisp/color.el index d572222021b..97656ca9e33 100644 --- a/lisp/color.el +++ b/lisp/color.el | |||
| @@ -93,7 +93,7 @@ resulting list." | |||
| 93 | "Compute hue from V1 and V2 H. | 93 | "Compute hue from V1 and V2 H. |
| 94 | Used internally by `color-hsl-to-rgb'." | 94 | Used internally by `color-hsl-to-rgb'." |
| 95 | (cond | 95 | (cond |
| 96 | ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) | 96 | ((< h (/ 6.0)) (+ v1 (* (- v2 v1) h 6.0))) |
| 97 | ((< h 0.5) v2) | 97 | ((< h 0.5) v2) |
| 98 | ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0))) | 98 | ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0))) |
| 99 | (t v1))) | 99 | (t v1))) |
| @@ -110,9 +110,9 @@ inclusive." | |||
| 110 | (- (+ L S) (* L S)))) | 110 | (- (+ L S) (* L S)))) |
| 111 | (m1 (- (* 2.0 L) m2))) | 111 | (m1 (- (* 2.0 L) m2))) |
| 112 | (list | 112 | (list |
| 113 | (color-hue-to-rgb m1 m2 (mod (+ H (/ 1.0 3)) 1)) | 113 | (color-hue-to-rgb m1 m2 (mod (+ H (/ 3.0)) 1)) |
| 114 | (color-hue-to-rgb m1 m2 H) | 114 | (color-hue-to-rgb m1 m2 H) |
| 115 | (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1)))))) | 115 | (color-hue-to-rgb m1 m2 (mod (- H (/ 3.0)) 1)))))) |
| 116 | 116 | ||
| 117 | (defun color-complement-hex (color) | 117 | (defun color-complement-hex (color) |
| 118 | "Return the color that is the complement of COLOR, in hexadecimal format." | 118 | "Return the color that is the complement of COLOR, in hexadecimal format." |
| @@ -199,13 +199,13 @@ RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive." | |||
| 199 | (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) | 199 | (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) |
| 200 | (list (if (<= r 0.0031308) | 200 | (list (if (<= r 0.0031308) |
| 201 | (* 12.92 r) | 201 | (* 12.92 r) |
| 202 | (- (* 1.055 (expt r (/ 1 2.4))) 0.055)) | 202 | (- (* 1.055 (expt r (/ 2.4))) 0.055)) |
| 203 | (if (<= g 0.0031308) | 203 | (if (<= g 0.0031308) |
| 204 | (* 12.92 g) | 204 | (* 12.92 g) |
| 205 | (- (* 1.055 (expt g (/ 1 2.4))) 0.055)) | 205 | (- (* 1.055 (expt g (/ 2.4))) 0.055)) |
| 206 | (if (<= b 0.0031308) | 206 | (if (<= b 0.0031308) |
| 207 | (* 12.92 b) | 207 | (* 12.92 b) |
| 208 | (- (* 1.055 (expt b (/ 1 2.4))) 0.055))))) | 208 | (- (* 1.055 (expt b (/ 2.4))) 0.055))))) |
| 209 | 209 | ||
| 210 | (defconst color-d65-xyz '(0.950455 1.0 1.088753) | 210 | (defconst color-d65-xyz '(0.950455 1.0 1.088753) |
| 211 | "D65 white point in CIE XYZ.") | 211 | "D65 white point in CIE XYZ.") |
| @@ -222,13 +222,13 @@ conversion. If omitted or nil, use `color-d65-xyz'." | |||
| 222 | (yr (/ Y Yr)) | 222 | (yr (/ Y Yr)) |
| 223 | (zr (/ Z Zr)) | 223 | (zr (/ Z Zr)) |
| 224 | (fx (if (> xr color-cie-ε) | 224 | (fx (if (> xr color-cie-ε) |
| 225 | (expt xr (/ 1 3.0)) | 225 | (expt xr (/ 3.0)) |
| 226 | (/ (+ (* color-cie-κ xr) 16) 116.0))) | 226 | (/ (+ (* color-cie-κ xr) 16) 116.0))) |
| 227 | (fy (if (> yr color-cie-ε) | 227 | (fy (if (> yr color-cie-ε) |
| 228 | (expt yr (/ 1 3.0)) | 228 | (expt yr (/ 3.0)) |
| 229 | (/ (+ (* color-cie-κ yr) 16) 116.0))) | 229 | (/ (+ (* color-cie-κ yr) 16) 116.0))) |
| 230 | (fz (if (> zr color-cie-ε) | 230 | (fz (if (> zr color-cie-ε) |
| 231 | (expt zr (/ 1 3.0)) | 231 | (expt zr (/ 3.0)) |
| 232 | (/ (+ (* color-cie-κ zr) 16) 116.0)))) | 232 | (/ (+ (* color-cie-κ zr) 16) 116.0)))) |
| 233 | (list | 233 | (list |
| 234 | (- (* 116 fy) 16) ; L | 234 | (- (* 116 fy) 16) ; L |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 6f7ba3353f6..d138effcd9d 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -3617,8 +3617,8 @@ discarding." | |||
| 3617 | 3617 | ||
| 3618 | (defun byte-compile-quo (form) | 3618 | (defun byte-compile-quo (form) |
| 3619 | (let ((len (length form))) | 3619 | (let ((len (length form))) |
| 3620 | (cond ((<= len 2) | 3620 | (cond ((< len 2) |
| 3621 | (byte-compile-subr-wrong-args form "2 or more")) | 3621 | (byte-compile-subr-wrong-args form "1 or more")) |
| 3622 | ((= len 3) | 3622 | ((= len 3) |
| 3623 | (byte-compile-two-args form)) | 3623 | (byte-compile-two-args form)) |
| 3624 | (t | 3624 | (t |
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index dddfca7ae83..afa021dffc7 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el | |||
| @@ -497,7 +497,7 @@ This sets the values of: `cl-most-positive-float', `cl-most-negative-float', | |||
| 497 | (setq cl-least-positive-normalized-float y | 497 | (setq cl-least-positive-normalized-float y |
| 498 | cl-least-negative-normalized-float (- y)) | 498 | cl-least-negative-normalized-float (- y)) |
| 499 | ;; Divide down until value underflows to zero. | 499 | ;; Divide down until value underflows to zero. |
| 500 | (setq x (/ 1 z) y x) | 500 | (setq x (/ z) y x) |
| 501 | (while (condition-case _ (> (/ x 2) 0) (arith-error nil)) | 501 | (while (condition-case _ (> (/ x 2) 0) (arith-error nil)) |
| 502 | (setq x (/ x 2))) | 502 | (setq x (/ x 2))) |
| 503 | (setq cl-least-positive-float x | 503 | (setq cl-least-positive-float x |
diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el index 482f829707d..f8d358c27b3 100644 --- a/lisp/net/shr-color.el +++ b/lisp/net/shr-color.el | |||
| @@ -211,7 +211,7 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"." | |||
| 211 | "Convert X Y H to RGB value." | 211 | "Convert X Y H to RGB value." |
| 212 | (when (< h 0) (incf h)) | 212 | (when (< h 0) (incf h)) |
| 213 | (when (> h 1) (decf h)) | 213 | (when (> h 1) (decf h)) |
| 214 | (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6))) | 214 | (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6))) |
| 215 | ((< h 0.5) y) | 215 | ((< h 0.5) y) |
| 216 | ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6))) | 216 | ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6))) |
| 217 | (t x))) | 217 | (t x))) |
| @@ -223,9 +223,9 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"." | |||
| 223 | (setq m2 (* l (+ s 1))) | 223 | (setq m2 (* l (+ s 1))) |
| 224 | (setq m2 (- (+ l s) (* l s)))) | 224 | (setq m2 (- (+ l s) (* l s)))) |
| 225 | (setq m1 (- (* l 2) m2)) | 225 | (setq m1 (- (* l 2) m2)) |
| 226 | (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 1 3.0))) | 226 | (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0))) |
| 227 | (shr-color-hue-to-rgb m1 m2 h) | 227 | (shr-color-hue-to-rgb m1 m2 h) |
| 228 | (shr-color-hue-to-rgb m1 m2 (- h (/ 1 3.0)))))) | 228 | (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0)))))) |
| 229 | 229 | ||
| 230 | (defun shr-color->hexadecimal (color) | 230 | (defun shr-color->hexadecimal (color) |
| 231 | "Convert any color format to hexadecimal representation. | 231 | "Convert any color format to hexadecimal representation. |
diff --git a/src/data.c b/src/data.c index b85d8a77106..33fe2855c99 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -2603,6 +2603,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) | |||
| 2603 | accum = 0; | 2603 | accum = 0; |
| 2604 | break; | 2604 | break; |
| 2605 | case Amult: | 2605 | case Amult: |
| 2606 | case Adiv: | ||
| 2606 | accum = 1; | 2607 | accum = 1; |
| 2607 | break; | 2608 | break; |
| 2608 | case Alogand: | 2609 | case Alogand: |
| @@ -2658,7 +2659,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) | |||
| 2658 | accum *= next; | 2659 | accum *= next; |
| 2659 | break; | 2660 | break; |
| 2660 | case Adiv: | 2661 | case Adiv: |
| 2661 | if (!argnum) | 2662 | if (! (argnum || nargs == 1)) |
| 2662 | accum = next; | 2663 | accum = next; |
| 2663 | else | 2664 | else |
| 2664 | { | 2665 | { |
| @@ -2727,7 +2728,7 @@ float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code, | |||
| 2727 | accum *= next; | 2728 | accum *= next; |
| 2728 | break; | 2729 | break; |
| 2729 | case Adiv: | 2730 | case Adiv: |
| 2730 | if (!argnum) | 2731 | if (! (argnum || nargs == 1)) |
| 2731 | accum = next; | 2732 | accum = next; |
| 2732 | else | 2733 | else |
| 2733 | { | 2734 | { |
| @@ -2782,9 +2783,11 @@ usage: (* &rest NUMBERS-OR-MARKERS) */) | |||
| 2782 | } | 2783 | } |
| 2783 | 2784 | ||
| 2784 | DEFUN ("/", Fquo, Squo, 1, MANY, 0, | 2785 | DEFUN ("/", Fquo, Squo, 1, MANY, 0, |
| 2785 | doc: /* Return first argument divided by all the remaining arguments. | 2786 | doc: /* Divide number by divisors and return the result. |
| 2787 | With two or more arguments, return first argument divided by the rest. | ||
| 2788 | With one argument, return 1 divided by the argument. | ||
| 2786 | The arguments must be numbers or markers. | 2789 | The arguments must be numbers or markers. |
| 2787 | usage: (/ DIVIDEND &rest DIVISORS) */) | 2790 | usage: (/ NUMBER &rest DIVISORS) */) |
| 2788 | (ptrdiff_t nargs, Lisp_Object *args) | 2791 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2789 | { | 2792 | { |
| 2790 | ptrdiff_t argnum; | 2793 | ptrdiff_t argnum; |