diff options
| author | Paul Eggert | 2011-05-04 23:31:14 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-05-04 23:31:14 -0700 |
| commit | c717b32678affe3864f0d5024a9de514c950214d (patch) | |
| tree | 5e682fb44780734c00be9a203499b7a8651e560c /doc | |
| parent | 852a74a59b12d505eba86a0aed46bfe8af7b9acf (diff) | |
| download | emacs-c717b32678affe3864f0d5024a9de514c950214d.tar.gz emacs-c717b32678affe3864f0d5024a9de514c950214d.zip | |
Revert to wraparound integer arithmetic, instead of going to float.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/ChangeLog | 3 | ||||
| -rw-r--r-- | doc/lispref/numbers.texi | 12 | ||||
| -rw-r--r-- | doc/lispref/objects.texi | 11 |
3 files changed, 11 insertions, 15 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index bca76b8a23c..163de31f220 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | 2011-05-03 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-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. (Bug#8611) | ||
| 7 | 4 | ||
| 8 | 2011-04-30 Lars Magne Ingebrigtsen <larsi@gnus.org> | 5 | 2011-04-30 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 9 | 6 | ||
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index ebf5660febe..2c73a03a26c 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 |
| 508 | if any argument is floating. | 508 | if any argument is floating. |
| 509 | 509 | ||
| 510 | If integer arithmetic overflows, the resulting value is converted | 510 | It is important to note that in Emacs Lisp, arithmetic functions |
| 511 | to floating point. Thus @code{(1+ 536870911)} may evaluate to | 511 | do not check for overflow. Thus @code{(1+ 268435455)} may evaluate to |
| 512 | 536870912.0, depending on your hardware. | 512 | @minus{}268435456, depending on your hardware. |
| 513 | 513 | ||
| 514 | @defun 1+ number-or-marker | 514 | @defun 1+ number-or-marker |
| 515 | This function returns @var{number-or-marker} plus 1. | 515 | 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: | |||
| 826 | As the example illustrates, shifting one place to the right divides the | 826 | As the example illustrates, shifting one place to the right divides the |
| 827 | value of a positive integer by two, rounding downward. | 827 | value of a positive integer by two, rounding downward. |
| 828 | 828 | ||
| 829 | The function @code{lsh} does | 829 | The function @code{lsh}, like all Emacs Lisp arithmetic functions, does |
| 830 | not check for overflow, so shifting left can discard significant bits | 830 | not check for overflow, so shifting left can discard significant bits |
| 831 | and change the sign of the number. For example, left shifting | 831 | and change the sign of the number. For example, left shifting |
| 832 | 536,870,911 produces @minus{}2 on a 30-bit machine: | 832 | 536,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 |
| 1171 | This function returns @var{x} raised to power @var{y}. If both | 1171 | This function returns @var{x} raised to power @var{y}. If both |
| 1172 | arguments are integers and @var{y} is nonnegative, the result is an | 1172 | arguments are integers and @var{y} is positive, the result is an |
| 1173 | integer if it is in Emacs integer range. | 1173 | integer; in this case, overflow causes truncation, so watch out. |
| 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 6dd7878e53b..c58d54f13fc 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 |
| 182 | on most machines. (Some machines may provide a wider range.) | 182 | on most machines. (Some machines may provide a wider range.) It is |
| 183 | If integer arithmetic overflows, the resulting value is converted | 183 | important to note that the Emacs Lisp arithmetic functions do not check |
| 184 | +to floating point. Thus @code{(1+ 536870911)} may evaluate to | 184 | for overflow. Thus @code{(1+ 536870911)} is @minus{}536870912 on most |
| 185 | +536870912.0, depending on your hardware. | 185 | machines. |
| 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 |
| 188 | optional sign at the beginning and an optional period at the end. The | 188 | optional sign at the beginning and an optional period at the end. The |
| @@ -195,8 +195,7 @@ leading @samp{+} or a final @samp{.}. | |||
| 195 | 1 ; @r{The integer 1.} | 195 | 1 ; @r{The integer 1.} |
| 196 | 1. ; @r{Also the integer 1.} | 196 | 1. ; @r{Also the integer 1.} |
| 197 | +1 ; @r{Also the integer 1.} | 197 | +1 ; @r{Also the integer 1.} |
| 198 | 1073741825 ; @r{The floating point number 1073741825.0,} | 198 | 1073741825 ; @r{Also the integer 1 on a 30-bit implementation.} |
| 199 | ; @r{on a 30-bit implementation.} | ||
| 200 | @end group | 199 | @end group |
| 201 | @end example | 200 | @end example |
| 202 | 201 | ||