diff options
| author | Paul Eggert | 2020-02-17 13:36:50 -0800 |
|---|---|---|
| committer | Paul Eggert | 2020-02-17 13:37:14 -0800 |
| commit | 4e5ac4b0c611571d3e7930a27693a3fe03be1f40 (patch) | |
| tree | ae140e823a9db35e6556d8c69476433f8af29970 | |
| parent | f765aad28baf946666eb225b97228038167fade8 (diff) | |
| download | emacs-4e5ac4b0c611571d3e7930a27693a3fe03be1f40.tar.gz emacs-4e5ac4b0c611571d3e7930a27693a3fe03be1f40.zip | |
Reorder discussion of integer basics
* doc/lispref/numbers.texi (Integer Basics): Put the fixnum/bignum
discussion at the end of the section, not at the start (Bug#39557).
| -rw-r--r-- | doc/lispref/numbers.texi | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index c8941eab736..4b9fdf24206 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi | |||
| @@ -34,39 +34,6 @@ numbers have a fixed amount of precision. | |||
| 34 | @node Integer Basics | 34 | @node Integer Basics |
| 35 | @section Integer Basics | 35 | @section Integer Basics |
| 36 | 36 | ||
| 37 | Integers in Emacs Lisp are not limited to the machine word size. | ||
| 38 | |||
| 39 | Under the hood, though, there are two kinds of integers: smaller | ||
| 40 | ones, called @dfn{fixnums}, and larger ones, called @dfn{bignums}. | ||
| 41 | Some functions in Emacs accept only fixnums. Also, while fixnums can | ||
| 42 | be compared for numeric equality with @code{eq}, bignums require | ||
| 43 | more-heavyweight equality predicates like @code{eql} and @code{=}. | ||
| 44 | |||
| 45 | The range of values for bignums is limited by the amount of main | ||
| 46 | memory, by machine characteristics such as the size of the word used | ||
| 47 | to represent a bignum's exponent, and by the @code{integer-width} | ||
| 48 | variable. These limits are typically much more generous than the | ||
| 49 | limits for fixnums. A bignum is never numerically equal to a fixnum; | ||
| 50 | if Emacs computes an integer in fixnum range, it represents the | ||
| 51 | integer as a fixnum, not a bignum. | ||
| 52 | |||
| 53 | The range of values for a fixnum depends on the machine. The | ||
| 54 | minimum range is @minus{}536,870,912 to 536,870,911 (30 bits; i.e., | ||
| 55 | @ifnottex | ||
| 56 | @minus{}2**29 | ||
| 57 | @end ifnottex | ||
| 58 | @tex | ||
| 59 | @math{-2^{29}} | ||
| 60 | @end tex | ||
| 61 | to | ||
| 62 | @ifnottex | ||
| 63 | 2**29 @minus{} 1), | ||
| 64 | @end ifnottex | ||
| 65 | @tex | ||
| 66 | @math{2^{29}-1}), | ||
| 67 | @end tex | ||
| 68 | but many machines provide a wider range. | ||
| 69 | |||
| 70 | The Lisp reader reads an integer as a nonempty sequence | 37 | The Lisp reader reads an integer as a nonempty sequence |
| 71 | of decimal digits with optional initial sign and optional | 38 | of decimal digits with optional initial sign and optional |
| 72 | final period. | 39 | final period. |
| @@ -145,6 +112,46 @@ arguments to such functions may be either numbers or markers, we often | |||
| 145 | give these arguments the name @var{number-or-marker}. When the argument | 112 | give these arguments the name @var{number-or-marker}. When the argument |
| 146 | value is a marker, its position value is used and its buffer is ignored. | 113 | value is a marker, its position value is used and its buffer is ignored. |
| 147 | 114 | ||
| 115 | In Emacs Lisp, text characters are represented by integers. Any | ||
| 116 | integer between zero and the value of @code{(max-char)}, inclusive, is | ||
| 117 | considered to be valid as a character. @xref{Character Codes}. | ||
| 118 | |||
| 119 | Integers in Emacs Lisp are not limited to the machine word size. | ||
| 120 | Under the hood, though, there are two kinds of integers: smaller ones, | ||
| 121 | called @dfn{fixnums}, and larger ones, called @dfn{bignums}. Although | ||
| 122 | Emacs Lisp code ordinarily should not depend on whether an integer is | ||
| 123 | a fixnum or a bignum, older Emacs versions support only fixnums, some | ||
| 124 | functions in Emacs still accept only fixnums, and older Emacs Lisp | ||
| 125 | code may have trouble when given bignums. For example, while older | ||
| 126 | Emacs Lisp code could safely compare integers for numeric equality | ||
| 127 | with @code{eq}, the presence of bignums means that equality predicates | ||
| 128 | like @code{eql} and @code{=} should now be used to compare integers. | ||
| 129 | |||
| 130 | The range of values for bignums is limited by the amount of main | ||
| 131 | memory, by machine characteristics such as the size of the word used | ||
| 132 | to represent a bignum's exponent, and by the @code{integer-width} | ||
| 133 | variable. These limits are typically much more generous than the | ||
| 134 | limits for fixnums. A bignum is never numerically equal to a fixnum; | ||
| 135 | if Emacs computes an integer in fixnum range, it represents the | ||
| 136 | integer as a fixnum, not a bignum. | ||
| 137 | |||
| 138 | The range of values for a fixnum depends on the machine. The | ||
| 139 | minimum range is @minus{}536,870,912 to 536,870,911 (30 bits; i.e., | ||
| 140 | @ifnottex | ||
| 141 | @minus{}2**29 | ||
| 142 | @end ifnottex | ||
| 143 | @tex | ||
| 144 | @math{-2^{29}} | ||
| 145 | @end tex | ||
| 146 | to | ||
| 147 | @ifnottex | ||
| 148 | 2**29 @minus{} 1), | ||
| 149 | @end ifnottex | ||
| 150 | @tex | ||
| 151 | @math{2^{29}-1}), | ||
| 152 | @end tex | ||
| 153 | but many machines provide a wider range. | ||
| 154 | |||
| 148 | @cindex largest fixnum | 155 | @cindex largest fixnum |
| 149 | @cindex maximum fixnum | 156 | @cindex maximum fixnum |
| 150 | @defvar most-positive-fixnum | 157 | @defvar most-positive-fixnum |
| @@ -207,10 +214,6 @@ Setting this variable to a large number can be costly if a computation | |||
| 207 | creates huge integers. | 214 | creates huge integers. |
| 208 | @end defvar | 215 | @end defvar |
| 209 | 216 | ||
| 210 | In Emacs Lisp, text characters are represented by integers. Any | ||
| 211 | integer between zero and the value of @code{(max-char)}, inclusive, is | ||
| 212 | considered to be valid as a character. @xref{Character Codes}. | ||
| 213 | |||
| 214 | @node Float Basics | 217 | @node Float Basics |
| 215 | @section Floating-Point Basics | 218 | @section Floating-Point Basics |
| 216 | 219 | ||