1 |
@c -*-texinfo-*- |
@c -*-texinfo-*- |
2 |
@c This is part of the GNU Emacs Lisp Reference Manual. |
@c This is part of the GNU Emacs Lisp Reference Manual. |
3 |
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 |
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2003 |
4 |
@c Free Software Foundation, Inc. |
@c Free Software Foundation, Inc. |
5 |
@c See the file elisp.texi for copying conditions. |
@c See the file elisp.texi for copying conditions. |
6 |
@setfilename ../info/numbers |
@setfilename ../info/numbers |
36 |
@section Integer Basics |
@section Integer Basics |
37 |
|
|
38 |
The range of values for an integer depends on the machine. The |
The range of values for an integer depends on the machine. The |
39 |
minimum range is @minus{}134217728 to 134217727 (28 bits; i.e., |
minimum range is @minus{}268435456 to 268435455 (29 bits; i.e., |
40 |
@ifnottex |
@ifnottex |
41 |
-2**27 |
-2**28 |
42 |
@end ifnottex |
@end ifnottex |
43 |
@tex |
@tex |
44 |
@math{-2^{27}} |
@math{-2^{28}} |
45 |
@end tex |
@end tex |
46 |
to |
to |
47 |
@ifnottex |
@ifnottex |
48 |
2**27 - 1), |
2**28 - 1), |
49 |
@end ifnottex |
@end ifnottex |
50 |
@tex |
@tex |
51 |
@math{2^{27}-1}), |
@math{2^{28}-1}), |
52 |
@end tex |
@end tex |
53 |
but some machines may provide a wider range. Many examples in this |
but some machines may provide a wider range. Many examples in this |
54 |
chapter assume an integer has 28 bits. |
chapter assume an integer has 29 bits. |
55 |
@cindex overflow |
@cindex overflow |
56 |
|
|
57 |
The Lisp reader reads an integer as a sequence of digits with optional |
The Lisp reader reads an integer as a sequence of digits with optional |
62 |
1. ; @r{The integer 1.} |
1. ; @r{The integer 1.} |
63 |
+1 ; @r{Also the integer 1.} |
+1 ; @r{Also the integer 1.} |
64 |
-1 ; @r{The integer @minus{}1.} |
-1 ; @r{The integer @minus{}1.} |
65 |
268435457 ; @r{Also the integer 1, due to overflow.} |
536870913 ; @r{Also the integer 1, due to overflow.} |
66 |
0 ; @r{The integer 0.} |
0 ; @r{The integer 0.} |
67 |
-0 ; @r{The integer 0.} |
-0 ; @r{The integer 0.} |
68 |
@end example |
@end example |
70 |
@cindex integers in specific radix |
@cindex integers in specific radix |
71 |
@cindex radix for reading an integer |
@cindex radix for reading an integer |
72 |
@cindex base for reading an integer |
@cindex base for reading an integer |
73 |
|
@cindex hex numbers |
74 |
|
@cindex octal numbers |
75 |
|
@cindex reading numbers in hex, octal, and binary |
76 |
In addition, the Lisp reader recognizes a syntax for integers in |
In addition, the Lisp reader recognizes a syntax for integers in |
77 |
bases other than 10: @samp{#B@var{integer}} reads @var{integer} in |
bases other than 10: @samp{#B@var{integer}} reads @var{integer} in |
78 |
binary (radix 2), @samp{#O@var{integer}} reads @var{integer} in octal |
binary (radix 2), @samp{#O@var{integer}} reads @var{integer} in octal |
86 |
bitwise operators (@pxref{Bitwise Operations}), it is often helpful to |
bitwise operators (@pxref{Bitwise Operations}), it is often helpful to |
87 |
view the numbers in their binary form. |
view the numbers in their binary form. |
88 |
|
|
89 |
In 28-bit binary, the decimal integer 5 looks like this: |
In 29-bit binary, the decimal integer 5 looks like this: |
90 |
|
|
91 |
@example |
@example |
92 |
0000 0000 0000 0000 0000 0000 0101 |
0 0000 0000 0000 0000 0000 0000 0101 |
93 |
@end example |
@end example |
94 |
|
|
95 |
@noindent |
@noindent |
99 |
The integer @minus{}1 looks like this: |
The integer @minus{}1 looks like this: |
100 |
|
|
101 |
@example |
@example |
102 |
1111 1111 1111 1111 1111 1111 1111 |
1 1111 1111 1111 1111 1111 1111 1111 |
103 |
@end example |
@end example |
104 |
|
|
105 |
@noindent |
@noindent |
106 |
@cindex two's complement |
@cindex two's complement |
107 |
@minus{}1 is represented as 28 ones. (This is called @dfn{two's |
@minus{}1 is represented as 29 ones. (This is called @dfn{two's |
108 |
complement} notation.) |
complement} notation.) |
109 |
|
|
110 |
The negative integer, @minus{}5, is creating by subtracting 4 from |
The negative integer, @minus{}5, is creating by subtracting 4 from |
112 |
@minus{}5 looks like this: |
@minus{}5 looks like this: |
113 |
|
|
114 |
@example |
@example |
115 |
1111 1111 1111 1111 1111 1111 1011 |
1 1111 1111 1111 1111 1111 1111 1011 |
116 |
@end example |
@end example |
117 |
|
|
118 |
In this implementation, the largest 28-bit binary integer value is |
In this implementation, the largest 29-bit binary integer value is |
119 |
134,217,727 in decimal. In binary, it looks like this: |
268,435,455 in decimal. In binary, it looks like this: |
120 |
|
|
121 |
@example |
@example |
122 |
0111 1111 1111 1111 1111 1111 1111 |
0 1111 1111 1111 1111 1111 1111 1111 |
123 |
@end example |
@end example |
124 |
|
|
125 |
Since the arithmetic functions do not check whether integers go |
Since the arithmetic functions do not check whether integers go |
126 |
outside their range, when you add 1 to 134,217,727, the value is the |
outside their range, when you add 1 to 268,435,455, the value is the |
127 |
negative integer @minus{}134,217,728: |
negative integer @minus{}268,435,456: |
128 |
|
|
129 |
@example |
@example |
130 |
(+ 1 134217727) |
(+ 1 268435455) |
131 |
@result{} -134217728 |
@result{} -268435456 |
132 |
@result{} 1000 0000 0000 0000 0000 0000 0000 |
@result{} 1 0000 0000 0000 0000 0000 0000 0000 |
133 |
@end example |
@end example |
134 |
|
|
135 |
Many of the functions described in this chapter accept markers for |
Many of the functions described in this chapter accept markers for |
163 |
value is 1500. They are all equivalent. You can also use a minus sign |
value is 1500. They are all equivalent. You can also use a minus sign |
164 |
to write negative floating point numbers, as in @samp{-1.0}. |
to write negative floating point numbers, as in @samp{-1.0}. |
165 |
|
|
166 |
@cindex IEEE floating point |
@cindex @acronym{IEEE} floating point |
167 |
@cindex positive infinity |
@cindex positive infinity |
168 |
@cindex negative infinity |
@cindex negative infinity |
169 |
@cindex infinity |
@cindex infinity |
170 |
@cindex NaN |
@cindex NaN |
171 |
Most modern computers support the IEEE floating point standard, which |
Most modern computers support the @acronym{IEEE} floating point standard, |
172 |
provides for positive infinity and negative infinity as floating point |
which provides for positive infinity and negative infinity as floating point |
173 |
values. It also provides for a class of values called NaN or |
values. It also provides for a class of values called NaN or |
174 |
``not-a-number''; numerical functions return such values in cases where |
``not-a-number''; numerical functions return such values in cases where |
175 |
there is no correct answer. For example, @code{(sqrt -1.0)} returns a |
there is no correct answer. For example, @code{(sqrt -1.0)} returns a |
189 |
@end table |
@end table |
190 |
|
|
191 |
In addition, the value @code{-0.0} is distinguishable from ordinary |
In addition, the value @code{-0.0} is distinguishable from ordinary |
192 |
zero in IEEE floating point (although @code{equal} and @code{=} consider |
zero in @acronym{IEEE} floating point (although @code{equal} and |
193 |
them equal values). |
@code{=} consider them equal values). |
194 |
|
|
195 |
You can use @code{logb} to extract the binary exponent of a floating |
You can use @code{logb} to extract the binary exponent of a floating |
196 |
point number (or estimate the logarithm of an integer): |
point number (or estimate the logarithm of an integer): |
379 |
@end defun |
@end defun |
380 |
|
|
381 |
There are four functions to convert floating point numbers to integers; |
There are four functions to convert floating point numbers to integers; |
382 |
they differ in how they round. These functions accept integer arguments |
they differ in how they round. All accept an argument @var{number} |
383 |
also, and return such arguments unchanged. |
and an optional argument @var{divisor}. Both arguments may be |
384 |
|
integers or floating point numbers. @var{divisor} may also be |
385 |
|
@code{nil}. If @var{divisor} is @code{nil} or omitted, these |
386 |
|
functions convert @var{number} to an integer, or return it unchanged |
387 |
|
if it already is an integer. If @var{divisor} is non-@code{nil}, they |
388 |
|
divide @var{number} by @var{divisor} and convert the result to an |
389 |
|
integer. An @code{arith-error} results if @var{divisor} is 0. |
390 |
|
|
391 |
@defun truncate number |
@defun truncate number &optional divisor |
392 |
This returns @var{number}, converted to an integer by rounding towards |
This returns @var{number}, converted to an integer by rounding towards |
393 |
zero. |
zero. |
394 |
|
|
408 |
This returns @var{number}, converted to an integer by rounding downward |
This returns @var{number}, converted to an integer by rounding downward |
409 |
(towards negative infinity). |
(towards negative infinity). |
410 |
|
|
411 |
If @var{divisor} is specified, @code{floor} divides @var{number} by |
If @var{divisor} is specified, this uses the kind of division |
412 |
@var{divisor} and then converts to an integer; this uses the kind of |
operation that corresponds to @code{mod}, rounding downward. |
|
division operation that corresponds to @code{mod}, rounding downward. |
|
|
An @code{arith-error} results if @var{divisor} is 0. |
|
413 |
|
|
414 |
@example |
@example |
415 |
(floor 1.2) |
(floor 1.2) |
425 |
@end example |
@end example |
426 |
@end defun |
@end defun |
427 |
|
|
428 |
@defun ceiling number |
@defun ceiling number &optional divisor |
429 |
This returns @var{number}, converted to an integer by rounding upward |
This returns @var{number}, converted to an integer by rounding upward |
430 |
(towards positive infinity). |
(towards positive infinity). |
431 |
|
|
441 |
@end example |
@end example |
442 |
@end defun |
@end defun |
443 |
|
|
444 |
@defun round number |
@defun round number &optional divisor |
445 |
This returns @var{number}, converted to an integer by rounding towards the |
This returns @var{number}, converted to an integer by rounding towards the |
446 |
nearest integer. Rounding a value equidistant between two integers |
nearest integer. Rounding a value equidistant between two integers |
447 |
may choose the integer closer to zero, or it may prefer an even integer, |
may choose the integer closer to zero, or it may prefer an even integer, |
472 |
if any argument is floating. |
if any argument is floating. |
473 |
|
|
474 |
It is important to note that in Emacs Lisp, arithmetic functions |
It is important to note that in Emacs Lisp, arithmetic functions |
475 |
do not check for overflow. Thus @code{(1+ 134217727)} may evaluate to |
do not check for overflow. Thus @code{(1+ 268435455)} may evaluate to |
476 |
@minus{}134217728, depending on your hardware. |
@minus{}268435456, depending on your hardware. |
477 |
|
|
478 |
@defun 1+ number-or-marker |
@defun 1+ number-or-marker |
479 |
This function returns @var{number-or-marker} plus 1. |
This function returns @var{number-or-marker} plus 1. |
569 |
@cindex @code{arith-error} in division |
@cindex @code{arith-error} in division |
570 |
If you divide an integer by 0, an @code{arith-error} error is signaled. |
If you divide an integer by 0, an @code{arith-error} error is signaled. |
571 |
(@xref{Errors}.) Floating point division by zero returns either |
(@xref{Errors}.) Floating point division by zero returns either |
572 |
infinity or a NaN if your machine supports IEEE floating point; |
infinity or a NaN if your machine supports @acronym{IEEE} floating point; |
573 |
otherwise, it signals an @code{arith-error} error. |
otherwise, it signals an @code{arith-error} error. |
574 |
|
|
575 |
@example |
@example |
792 |
The function @code{lsh}, like all Emacs Lisp arithmetic functions, does |
The function @code{lsh}, like all Emacs Lisp arithmetic functions, does |
793 |
not check for overflow, so shifting left can discard significant bits |
not check for overflow, so shifting left can discard significant bits |
794 |
and change the sign of the number. For example, left shifting |
and change the sign of the number. For example, left shifting |
795 |
134,217,727 produces @minus{}2 on a 28-bit machine: |
268,435,455 produces @minus{}2 on a 29-bit machine: |
796 |
|
|
797 |
@example |
@example |
798 |
(lsh 134217727 1) ; @r{left shift} |
(lsh 268435455 1) ; @r{left shift} |
799 |
@result{} -2 |
@result{} -2 |
800 |
@end example |
@end example |
801 |
|
|
802 |
In binary, in the 28-bit implementation, the argument looks like this: |
In binary, in the 29-bit implementation, the argument looks like this: |
803 |
|
|
804 |
@example |
@example |
805 |
@group |
@group |
806 |
;; @r{Decimal 134,217,727} |
;; @r{Decimal 268,435,455} |
807 |
0111 1111 1111 1111 1111 1111 1111 |
0 1111 1111 1111 1111 1111 1111 1111 |
808 |
@end group |
@end group |
809 |
@end example |
@end example |
810 |
|
|
814 |
@example |
@example |
815 |
@group |
@group |
816 |
;; @r{Decimal @minus{}2} |
;; @r{Decimal @minus{}2} |
817 |
1111 1111 1111 1111 1111 1111 1110 |
1 1111 1111 1111 1111 1111 1111 1110 |
818 |
@end group |
@end group |
819 |
@end example |
@end example |
820 |
@end defun |
@end defun |
837 |
@group |
@group |
838 |
(ash -6 -1) @result{} -3 |
(ash -6 -1) @result{} -3 |
839 |
;; @r{Decimal @minus{}6 becomes decimal @minus{}3.} |
;; @r{Decimal @minus{}6 becomes decimal @minus{}3.} |
840 |
1111 1111 1111 1111 1111 1111 1010 |
1 1111 1111 1111 1111 1111 1111 1010 |
841 |
@result{} |
@result{} |
842 |
1111 1111 1111 1111 1111 1111 1101 |
1 1111 1111 1111 1111 1111 1111 1101 |
843 |
@end group |
@end group |
844 |
@end example |
@end example |
845 |
|
|
848 |
|
|
849 |
@example |
@example |
850 |
@group |
@group |
851 |
(lsh -6 -1) @result{} 134217725 |
(lsh -6 -1) @result{} 268435453 |
852 |
;; @r{Decimal @minus{}6 becomes decimal 134,217,725.} |
;; @r{Decimal @minus{}6 becomes decimal 268,435,453.} |
853 |
1111 1111 1111 1111 1111 1111 1010 |
1 1111 1111 1111 1111 1111 1111 1010 |
854 |
@result{} |
@result{} |
855 |
0111 1111 1111 1111 1111 1111 1101 |
0 1111 1111 1111 1111 1111 1111 1101 |
856 |
@end group |
@end group |
857 |
@end example |
@end example |
858 |
|
|
862 |
@c with smallbook but not with regular book! --rjc 16mar92 |
@c with smallbook but not with regular book! --rjc 16mar92 |
863 |
@smallexample |
@smallexample |
864 |
@group |
@group |
865 |
; @r{ 28-bit binary values} |
; @r{ 29-bit binary values} |
866 |
|
|
867 |
(lsh 5 2) ; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
(lsh 5 2) ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
868 |
@result{} 20 ; = @r{0000 0000 0000 0000 0000 0001 0100} |
@result{} 20 ; = @r{0 0000 0000 0000 0000 0000 0001 0100} |
869 |
@end group |
@end group |
870 |
@group |
@group |
871 |
(ash 5 2) |
(ash 5 2) |
872 |
@result{} 20 |
@result{} 20 |
873 |
(lsh -5 2) ; -5 = @r{1111 1111 1111 1111 1111 1111 1011} |
(lsh -5 2) ; -5 = @r{1 1111 1111 1111 1111 1111 1111 1011} |
874 |
@result{} -20 ; = @r{1111 1111 1111 1111 1111 1110 1100} |
@result{} -20 ; = @r{1 1111 1111 1111 1111 1111 1110 1100} |
875 |
(ash -5 2) |
(ash -5 2) |
876 |
@result{} -20 |
@result{} -20 |
877 |
@end group |
@end group |
878 |
@group |
@group |
879 |
(lsh 5 -2) ; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
(lsh 5 -2) ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
880 |
@result{} 1 ; = @r{0000 0000 0000 0000 0000 0000 0001} |
@result{} 1 ; = @r{0 0000 0000 0000 0000 0000 0000 0001} |
881 |
@end group |
@end group |
882 |
@group |
@group |
883 |
(ash 5 -2) |
(ash 5 -2) |
884 |
@result{} 1 |
@result{} 1 |
885 |
@end group |
@end group |
886 |
@group |
@group |
887 |
(lsh -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1111 1011} |
(lsh -5 -2) ; -5 = @r{1 1111 1111 1111 1111 1111 1111 1011} |
888 |
@result{} 4194302 ; = @r{0011 1111 1111 1111 1111 1111 1110} |
@result{} 134217726 ; = @r{0 0111 1111 1111 1111 1111 1111 1110} |
889 |
@end group |
@end group |
890 |
@group |
@group |
891 |
(ash -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1111 1011} |
(ash -5 -2) ; -5 = @r{1 1111 1111 1111 1111 1111 1111 1011} |
892 |
@result{} -2 ; = @r{1111 1111 1111 1111 1111 1111 1110} |
@result{} -2 ; = @r{1 1111 1111 1111 1111 1111 1111 1110} |
893 |
@end group |
@end group |
894 |
@end smallexample |
@end smallexample |
895 |
@end defun |
@end defun |
926 |
|
|
927 |
@smallexample |
@smallexample |
928 |
@group |
@group |
929 |
; @r{ 28-bit binary values} |
; @r{ 29-bit binary values} |
930 |
|
|
931 |
(logand 14 13) ; 14 = @r{0000 0000 0000 0000 0000 0000 1110} |
(logand 14 13) ; 14 = @r{0 0000 0000 0000 0000 0000 0000 1110} |
932 |
; 13 = @r{0000 0000 0000 0000 0000 0000 1101} |
; 13 = @r{0 0000 0000 0000 0000 0000 0000 1101} |
933 |
@result{} 12 ; 12 = @r{0000 0000 0000 0000 0000 0000 1100} |
@result{} 12 ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} |
934 |
@end group |
@end group |
935 |
|
|
936 |
@group |
@group |
937 |
(logand 14 13 4) ; 14 = @r{0000 0000 0000 0000 0000 0000 1110} |
(logand 14 13 4) ; 14 = @r{0 0000 0000 0000 0000 0000 0000 1110} |
938 |
; 13 = @r{0000 0000 0000 0000 0000 0000 1101} |
; 13 = @r{0 0000 0000 0000 0000 0000 0000 1101} |
939 |
; 4 = @r{0000 0000 0000 0000 0000 0000 0100} |
; 4 = @r{0 0000 0000 0000 0000 0000 0000 0100} |
940 |
@result{} 4 ; 4 = @r{0000 0000 0000 0000 0000 0000 0100} |
@result{} 4 ; 4 = @r{0 0000 0000 0000 0000 0000 0000 0100} |
941 |
@end group |
@end group |
942 |
|
|
943 |
@group |
@group |
944 |
(logand) |
(logand) |
945 |
@result{} -1 ; -1 = @r{1111 1111 1111 1111 1111 1111 1111} |
@result{} -1 ; -1 = @r{1 1111 1111 1111 1111 1111 1111 1111} |
946 |
@end group |
@end group |
947 |
@end smallexample |
@end smallexample |
948 |
@end defun |
@end defun |
958 |
|
|
959 |
@smallexample |
@smallexample |
960 |
@group |
@group |
961 |
; @r{ 28-bit binary values} |
; @r{ 29-bit binary values} |
962 |
|
|
963 |
(logior 12 5) ; 12 = @r{0000 0000 0000 0000 0000 0000 1100} |
(logior 12 5) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} |
964 |
; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
965 |
@result{} 13 ; 13 = @r{0000 0000 0000 0000 0000 0000 1101} |
@result{} 13 ; 13 = @r{0 0000 0000 0000 0000 0000 0000 1101} |
966 |
@end group |
@end group |
967 |
|
|
968 |
@group |
@group |
969 |
(logior 12 5 7) ; 12 = @r{0000 0000 0000 0000 0000 0000 1100} |
(logior 12 5 7) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} |
970 |
; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
971 |
; 7 = @r{0000 0000 0000 0000 0000 0000 0111} |
; 7 = @r{0 0000 0000 0000 0000 0000 0000 0111} |
972 |
@result{} 15 ; 15 = @r{0000 0000 0000 0000 0000 0000 1111} |
@result{} 15 ; 15 = @r{0 0000 0000 0000 0000 0000 0000 1111} |
973 |
@end group |
@end group |
974 |
@end smallexample |
@end smallexample |
975 |
@end defun |
@end defun |
985 |
|
|
986 |
@smallexample |
@smallexample |
987 |
@group |
@group |
988 |
; @r{ 28-bit binary values} |
; @r{ 29-bit binary values} |
989 |
|
|
990 |
(logxor 12 5) ; 12 = @r{0000 0000 0000 0000 0000 0000 1100} |
(logxor 12 5) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} |
991 |
; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
992 |
@result{} 9 ; 9 = @r{0000 0000 0000 0000 0000 0000 1001} |
@result{} 9 ; 9 = @r{0 0000 0000 0000 0000 0000 0000 1001} |
993 |
@end group |
@end group |
994 |
|
|
995 |
@group |
@group |
996 |
(logxor 12 5 7) ; 12 = @r{0000 0000 0000 0000 0000 0000 1100} |
(logxor 12 5 7) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} |
997 |
; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
998 |
; 7 = @r{0000 0000 0000 0000 0000 0000 0111} |
; 7 = @r{0 0000 0000 0000 0000 0000 0000 0111} |
999 |
@result{} 14 ; 14 = @r{0000 0000 0000 0000 0000 0000 1110} |
@result{} 14 ; 14 = @r{0 0000 0000 0000 0000 0000 0000 1110} |
1000 |
@end group |
@end group |
1001 |
@end smallexample |
@end smallexample |
1002 |
@end defun |
@end defun |
1011 |
@example |
@example |
1012 |
(lognot 5) |
(lognot 5) |
1013 |
@result{} -6 |
@result{} -6 |
1014 |
;; 5 = @r{0000 0000 0000 0000 0000 0000 0101} |
;; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} |
1015 |
;; @r{becomes} |
;; @r{becomes} |
1016 |
;; -6 = @r{1111 1111 1111 1111 1111 1111 1010} |
;; -6 = @r{1 1111 1111 1111 1111 1111 1111 1010} |
1017 |
@end example |
@end example |
1018 |
@end defun |
@end defun |
1019 |
|
|
1170 |
|
|
1171 |
If you want random numbers that don't always come out the same, execute |
If you want random numbers that don't always come out the same, execute |
1172 |
@code{(random t)}. This chooses a new seed based on the current time of |
@code{(random t)}. This chooses a new seed based on the current time of |
1173 |
day and on Emacs's process @sc{id} number. |
day and on Emacs's process @acronym{ID} number. |
1174 |
|
|
1175 |
@defun random &optional limit |
@defun random &optional limit |
1176 |
This function returns a pseudo-random integer. Repeated calls return a |
This function returns a pseudo-random integer. Repeated calls return a |
1180 |
nonnegative and less than @var{limit}. |
nonnegative and less than @var{limit}. |
1181 |
|
|
1182 |
If @var{limit} is @code{t}, it means to choose a new seed based on the |
If @var{limit} is @code{t}, it means to choose a new seed based on the |
1183 |
current time of day and on Emacs's process @sc{id} number. |
current time of day and on Emacs's process @acronym{ID} number. |
1184 |
@c "Emacs'" is incorrect usage! |
@c "Emacs'" is incorrect usage! |
1185 |
|
|
1186 |
On some machines, any integer representable in Lisp may be the result |
On some machines, any integer representable in Lisp may be the result |