[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.
This commit is contained in:
parent
4ed0cebda8
commit
680186416d
5 changed files with 26 additions and 11 deletions
|
@ -1,6 +1,9 @@
|
|||
2011-05-03 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* numbers.texi (Integer Basics): Large integers are treated as floats.
|
||||
(Arithmetic Operations, Math Functions): Large integers go to
|
||||
floats instead of wrapping around.
|
||||
* objects.texi (Integer Type): Likewise.
|
||||
|
||||
2011-04-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
|
|
|
@ -507,9 +507,9 @@ commonly used.
|
|||
All of these functions except @code{%} return a floating point value
|
||||
if any argument is floating.
|
||||
|
||||
It is important to note that in Emacs Lisp, arithmetic functions
|
||||
do not check for overflow. Thus @code{(1+ 268435455)} may evaluate to
|
||||
@minus{}268435456, depending on your hardware.
|
||||
If integer arithmetic overflows, the resulting value is converted
|
||||
to floating point. Thus @code{(1+ 536870911)} may evaluate to
|
||||
536870912.0, depending on your hardware.
|
||||
|
||||
@defun 1+ number-or-marker
|
||||
This 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:
|
|||
As the example illustrates, shifting one place to the right divides the
|
||||
value of a positive integer by two, rounding downward.
|
||||
|
||||
The function @code{lsh}, like all Emacs Lisp arithmetic functions, does
|
||||
The function @code{lsh} does
|
||||
not check for overflow, so shifting left can discard significant bits
|
||||
and change the sign of the number. For example, left shifting
|
||||
536,870,911 produces @minus{}2 on a 30-bit machine:
|
||||
|
@ -1169,8 +1169,8 @@ approximately.
|
|||
|
||||
@defun expt x y
|
||||
This function returns @var{x} raised to power @var{y}. If both
|
||||
arguments are integers and @var{y} is positive, the result is an
|
||||
integer; in this case, overflow causes truncation, so watch out.
|
||||
arguments are integers and @var{y} is nonnegative, the result is an
|
||||
integer if it is in Emacs integer range.
|
||||
@end defun
|
||||
|
||||
@defun sqrt arg
|
||||
|
|
|
@ -179,10 +179,10 @@ to
|
|||
@tex
|
||||
@math{2^{29}-1})
|
||||
@end tex
|
||||
on most machines. (Some machines may provide a wider range.) It is
|
||||
important to note that the Emacs Lisp arithmetic functions do not check
|
||||
for overflow. Thus @code{(1+ 536870911)} is @minus{}536870912 on most
|
||||
machines.
|
||||
on most machines. (Some machines may provide a wider range.)
|
||||
If integer arithmetic overflows, the resulting value is converted
|
||||
+to floating point. Thus @code{(1+ 536870911)} may evaluate to
|
||||
+536870912.0, depending on your hardware.
|
||||
|
||||
The read syntax for integers is a sequence of (base ten) digits with an
|
||||
optional sign at the beginning and an optional period at the end. The
|
||||
|
@ -195,7 +195,8 @@ leading @samp{+} or a final @samp{.}.
|
|||
1 ; @r{The integer 1.}
|
||||
1. ; @r{Also the integer 1.}
|
||||
+1 ; @r{Also the integer 1.}
|
||||
1073741825 ; @r{Also the integer 1 on a 30-bit implementation.}
|
||||
1073741825 ; @r{The floating point number 1073741825.0,}
|
||||
; @r{on a 30-bit implementation.}
|
||||
@end group
|
||||
@end example
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2011-05-03 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* NEWS: Integer overflow now yields floating-point instead of
|
||||
wrapping around.
|
||||
|
||||
2011-05-03 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* NEWS: Mention the new command isearch-yank-pop.
|
||||
|
|
6
etc/NEWS
6
etc/NEWS
|
@ -728,6 +728,12 @@ soap-inspect.el is an interactive inspector for SOAP WSDL structures.
|
|||
|
||||
* Incompatible Lisp Changes in Emacs 24.1
|
||||
|
||||
+++
|
||||
** Integer arithmetic overflow now yields the nearest floating-piont
|
||||
value rather than wrapping around. For example, on a 32-bit machine,
|
||||
(1+ 536870911) yields 536870912.0, instead of the -536870912 it
|
||||
yielded in Emacs 23.3, or the 0 it yielded in Emacs 23.1.
|
||||
|
||||
---
|
||||
** `char-direction-table' and the associated function `char-direction'
|
||||
were deleted. They were buggy and inferior to the new support of
|
||||
|
|
Loading…
Add table
Reference in a new issue