aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-05-03 09:33:36 -0700
committerPaul Eggert2011-05-03 09:33:36 -0700
commit680186416d09efb9c3b4599ee848e3bb9fe184b6 (patch)
tree83fe8f6f252befa375abcd0186aab683bacfcb0d
parent4ed0cebda869315a9e729daa55c50a16e2a5cde1 (diff)
downloademacs-680186416d09efb9c3b4599ee848e3bb9fe184b6.tar.gz
emacs-680186416d09efb9c3b4599ee848e3bb9fe184b6.zip
[etc/ChangeLog]
* NEWS: Integer overflow now yields floating-point instead of wrapping around. [doc/lispref/ChangeLog] * numbers.texi (Arithmetic Operations, Math Functions): Large integers go to floats instead of wrapping around. * objects.texi (Integer Type): Likewise.
-rw-r--r--doc/lispref/ChangeLog3
-rw-r--r--doc/lispref/numbers.texi12
-rw-r--r--doc/lispref/objects.texi11
-rw-r--r--etc/ChangeLog5
-rw-r--r--etc/NEWS6
5 files changed, 26 insertions, 11 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 163de31f220..a48fa634cb7 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,6 +1,9 @@
12011-05-03 Paul Eggert <eggert@cs.ucla.edu> 12011-05-03 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * numbers.texi (Integer Basics): Large integers are treated as floats. 3 * numbers.texi (Integer Basics): Large integers are treated as floats.
4 (Arithmetic Operations, Math Functions): Large integers go to
5 floats instead of wrapping around.
6 * objects.texi (Integer Type): Likewise.
4 7
52011-04-30 Lars Magne Ingebrigtsen <larsi@gnus.org> 82011-04-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
6 9
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index 2c73a03a26c..ebf5660febe 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -507,9 +507,9 @@ commonly used.
507 All of these functions except @code{%} return a floating point value 507 All of these functions except @code{%} return a floating point value
508if any argument is floating. 508if any argument is floating.
509 509
510 It is important to note that in Emacs Lisp, arithmetic functions 510 If integer arithmetic overflows, the resulting value is converted
511do not check for overflow. Thus @code{(1+ 268435455)} may evaluate to 511to floating point. Thus @code{(1+ 536870911)} may evaluate to
512@minus{}268435456, depending on your hardware. 512536870912.0, depending on your hardware.
513 513
514@defun 1+ number-or-marker 514@defun 1+ number-or-marker
515This function returns @var{number-or-marker} plus 1. 515This function returns @var{number-or-marker} plus 1.
@@ -826,7 +826,7 @@ On the other hand, shifting one place to the right looks like this:
826As the example illustrates, shifting one place to the right divides the 826As the example illustrates, shifting one place to the right divides the
827value of a positive integer by two, rounding downward. 827value of a positive integer by two, rounding downward.
828 828
829The function @code{lsh}, like all Emacs Lisp arithmetic functions, does 829The function @code{lsh} does
830not check for overflow, so shifting left can discard significant bits 830not check for overflow, so shifting left can discard significant bits
831and change the sign of the number. For example, left shifting 831and change the sign of the number. For example, left shifting
832536,870,911 produces @minus{}2 on a 30-bit machine: 832536,870,911 produces @minus{}2 on a 30-bit machine:
@@ -1169,8 +1169,8 @@ approximately.
1169 1169
1170@defun expt x y 1170@defun expt x y
1171This function returns @var{x} raised to power @var{y}. If both 1171This function returns @var{x} raised to power @var{y}. If both
1172arguments are integers and @var{y} is positive, the result is an 1172arguments are integers and @var{y} is nonnegative, the result is an
1173integer; in this case, overflow causes truncation, so watch out. 1173integer if it is in Emacs integer range.
1174@end defun 1174@end defun
1175 1175
1176@defun sqrt arg 1176@defun sqrt arg
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index c58d54f13fc..6dd7878e53b 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -179,10 +179,10 @@ to
179@tex 179@tex
180@math{2^{29}-1}) 180@math{2^{29}-1})
181@end tex 181@end tex
182on most machines. (Some machines may provide a wider range.) It is 182on most machines. (Some machines may provide a wider range.)
183important to note that the Emacs Lisp arithmetic functions do not check 183If integer arithmetic overflows, the resulting value is converted
184for overflow. Thus @code{(1+ 536870911)} is @minus{}536870912 on most 184+to floating point. Thus @code{(1+ 536870911)} may evaluate to
185machines. 185+536870912.0, depending on your hardware.
186 186
187 The read syntax for integers is a sequence of (base ten) digits with an 187 The read syntax for integers is a sequence of (base ten) digits with an
188optional sign at the beginning and an optional period at the end. The 188optional sign at the beginning and an optional period at the end. The
@@ -195,7 +195,8 @@ leading @samp{+} or a final @samp{.}.
1951 ; @r{The integer 1.} 1951 ; @r{The integer 1.}
1961. ; @r{Also the integer 1.} 1961. ; @r{Also the integer 1.}
197+1 ; @r{Also the integer 1.} 197+1 ; @r{Also the integer 1.}
1981073741825 ; @r{Also the integer 1 on a 30-bit implementation.} 1981073741825 ; @r{The floating point number 1073741825.0,}
199 ; @r{on a 30-bit implementation.}
199@end group 200@end group
200@end example 201@end example
201 202
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 0eb21406105..bd91ccc1c39 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,8 @@
12011-05-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 * NEWS: Integer overflow now yields floating-point instead of
4 wrapping around.
5
12011-05-03 Leo Liu <sdl.web@gmail.com> 62011-05-03 Leo Liu <sdl.web@gmail.com>
2 7
3 * NEWS: Mention the new command isearch-yank-pop. 8 * NEWS: Mention the new command isearch-yank-pop.
diff --git a/etc/NEWS b/etc/NEWS
index 5094ecfc4fc..669c143ba7f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -728,6 +728,12 @@ soap-inspect.el is an interactive inspector for SOAP WSDL structures.
728 728
729* Incompatible Lisp Changes in Emacs 24.1 729* Incompatible Lisp Changes in Emacs 24.1
730 730
731+++
732** Integer arithmetic overflow now yields the nearest floating-piont
733value rather than wrapping around. For example, on a 32-bit machine,
734(1+ 536870911) yields 536870912.0, instead of the -536870912 it
735yielded in Emacs 23.3, or the 0 it yielded in Emacs 23.1.
736
731--- 737---
732** `char-direction-table' and the associated function `char-direction' 738** `char-direction-table' and the associated function `char-direction'
733were deleted. They were buggy and inferior to the new support of 739were deleted. They were buggy and inferior to the new support of