summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-10-20 18:16:47 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-10-20 18:22:48 -0700
commite9af822ac3ddf9644aa4a68e56b0580e133449b2 (patch)
tree55b2ae836adac54903d43ee77e2730a0e2ac86bd /src
parent513fe25a501b41f9f2aac67f73c8e8730aed81b0 (diff)
downloademacs-e9af822ac3ddf9644aa4a68e56b0580e133449b2.tar.gz
(/ 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.
Diffstat (limited to 'src')
-rw-r--r--src/data.c11
1 files changed, 7 insertions, 4 deletions
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)
accum = 0;
break;
case Amult:
+ case Adiv:
accum = 1;
break;
case Alogand:
@@ -2658,7 +2659,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args)
accum *= next;
break;
case Adiv:
- if (!argnum)
+ if (! (argnum || nargs == 1))
accum = next;
else
{
@@ -2727,7 +2728,7 @@ float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code,
accum *= next;
break;
case Adiv:
- if (!argnum)
+ if (! (argnum || nargs == 1))
accum = next;
else
{
@@ -2782,9 +2783,11 @@ usage: (* &rest NUMBERS-OR-MARKERS) */)
}
DEFUN ("/", Fquo, Squo, 1, MANY, 0,
- doc: /* Return first argument divided by all the remaining arguments.
+ doc: /* Divide number by divisors and return the result.
+With two or more arguments, return first argument divided by the rest.
+With one argument, return 1 divided by the argument.
The arguments must be numbers or markers.
-usage: (/ DIVIDEND &rest DIVISORS) */)
+usage: (/ NUMBER &rest DIVISORS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
ptrdiff_t argnum;