aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-03-02 19:50:15 -0800
committerGlenn Morris2010-03-02 19:50:15 -0800
commit1ddd6622975d5bfeb6aceb2956f9ca8ca4a8b119 (patch)
treeaba6f39bb46b00c3d3671a0fc776cef23068affd
parent855dc98c537fad49ddc6ef94b0a881a5feb2ff65 (diff)
downloademacs-1ddd6622975d5bfeb6aceb2956f9ca8ca4a8b119.tar.gz
emacs-1ddd6622975d5bfeb6aceb2956f9ca8ca4a8b119.zip
Update Lispref for 30-bit integers.
* numbers.texi (Integer Basics, Bitwise Operations): * objects.texi (Integer Type): Update for integers now being 30-bit.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/numbers.texi143
-rw-r--r--doc/lispref/objects.texi16
3 files changed, 85 insertions, 79 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 26314eadc8e..755e83b65ef 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12010-03-03 Glenn Morris <rgm@gnu.org>
2
3 * numbers.texi (Integer Basics, Bitwise Operations):
4 * objects.texi (Integer Type): Update for integers now being 30-bit.
5
12010-02-27 Chong Yidong <cyd@stupidchicken.com> 62010-02-27 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * display.texi (Low-Level Font): Document :otf font-spec property. 8 * display.texi (Low-Level Font): Document :otf font-spec property.
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index a23721f1a84..fdec0448e02 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -1,7 +1,8 @@
1@c -*-texinfo-*- 1@c -*-texinfo-*-
2@c This is part of the GNU Emacs Lisp Reference Manual. 2@c This is part of the GNU Emacs Lisp Reference Manual.
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
4@c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4@c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5@c Free Software Foundation, Inc.
5@c See the file elisp.texi for copying conditions. 6@c See the file elisp.texi for copying conditions.
6@setfilename ../../info/numbers 7@setfilename ../../info/numbers
7@node Numbers, Strings and Characters, Lisp Data Types, Top 8@node Numbers, Strings and Characters, Lisp Data Types, Top
@@ -36,22 +37,22 @@ exact; they have a fixed, limited amount of precision.
36@section Integer Basics 37@section Integer Basics
37 38
38 The range of values for an integer depends on the machine. The 39 The range of values for an integer depends on the machine. The
39minimum range is @minus{}268435456 to 268435455 (29 bits; i.e., 40minimum range is @minus{}536870912 to 536870911 (30 bits; i.e.,
40@ifnottex 41@ifnottex
41-2**28 42-2**29
42@end ifnottex 43@end ifnottex
43@tex 44@tex
44@math{-2^{28}} 45@math{-2^{29}}
45@end tex 46@end tex
46to 47to
47@ifnottex 48@ifnottex
482**28 - 1), 492**29 - 1),
49@end ifnottex 50@end ifnottex
50@tex 51@tex
51@math{2^{28}-1}), 52@math{2^{29}-1}),
52@end tex 53@end tex
53but some machines may provide a wider range. Many examples in this 54but some machines may provide a wider range. Many examples in this
54chapter assume an integer has 29 bits. 55chapter assume an integer has 30 bits.
55@cindex overflow 56@cindex overflow
56 57
57 The Lisp reader reads an integer as a sequence of digits with optional 58 The Lisp reader reads an integer as a sequence of digits with optional
@@ -62,7 +63,7 @@ initial sign and optional final period.
62 1. ; @r{The integer 1.} 63 1. ; @r{The integer 1.}
63+1 ; @r{Also the integer 1.} 64+1 ; @r{Also the integer 1.}
64-1 ; @r{The integer @minus{}1.} 65-1 ; @r{The integer @minus{}1.}
65 536870913 ; @r{Also the integer 1, due to overflow.} 66 1073741825 ; @r{Also the integer 1, due to overflow.}
66 0 ; @r{The integer 0.} 67 0 ; @r{The integer 0.}
67-0 ; @r{The integer 0.} 68-0 ; @r{The integer 0.}
68@end example 69@end example
@@ -93,10 +94,10 @@ from 2 to 36. For example:
93bitwise operators (@pxref{Bitwise Operations}), it is often helpful to 94bitwise operators (@pxref{Bitwise Operations}), it is often helpful to
94view the numbers in their binary form. 95view the numbers in their binary form.
95 96
96 In 29-bit binary, the decimal integer 5 looks like this: 97 In 30-bit binary, the decimal integer 5 looks like this:
97 98
98@example 99@example
990 0000 0000 0000 0000 0000 0000 0101 10000 0000 0000 0000 0000 0000 0000 0101
100@end example 101@end example
101 102
102@noindent 103@noindent
@@ -106,12 +107,12 @@ between groups of 8 bits, to make the binary integer easier to read.)
106 The integer @minus{}1 looks like this: 107 The integer @minus{}1 looks like this:
107 108
108@example 109@example
1091 1111 1111 1111 1111 1111 1111 1111 11011 1111 1111 1111 1111 1111 1111 1111
110@end example 111@end example
111 112
112@noindent 113@noindent
113@cindex two's complement 114@cindex two's complement
114@minus{}1 is represented as 29 ones. (This is called @dfn{two's 115@minus{}1 is represented as 30 ones. (This is called @dfn{two's
115complement} notation.) 116complement} notation.)
116 117
117 The negative integer, @minus{}5, is creating by subtracting 4 from 118 The negative integer, @minus{}5, is creating by subtracting 4 from
@@ -119,24 +120,24 @@ complement} notation.)
119@minus{}5 looks like this: 120@minus{}5 looks like this:
120 121
121@example 122@example
1221 1111 1111 1111 1111 1111 1111 1011 12311 1111 1111 1111 1111 1111 1111 1011
123@end example 124@end example
124 125
125 In this implementation, the largest 29-bit binary integer value is 126 In this implementation, the largest 30-bit binary integer value is
126268,435,455 in decimal. In binary, it looks like this: 127536,870,911 in decimal. In binary, it looks like this:
127 128
128@example 129@example
1290 1111 1111 1111 1111 1111 1111 1111 13001 1111 1111 1111 1111 1111 1111 1111
130@end example 131@end example
131 132
132 Since the arithmetic functions do not check whether integers go 133 Since the arithmetic functions do not check whether integers go
133outside their range, when you add 1 to 268,435,455, the value is the 134outside their range, when you add 1 to 536,870,911, the value is the
134negative integer @minus{}268,435,456: 135negative integer @minus{}536,870,912:
135 136
136@example 137@example
137(+ 1 268435455) 138(+ 1 536870911)
138 @result{} -268435456 139 @result{} -536870912
139 @result{} 1 0000 0000 0000 0000 0000 0000 0000 140 @result{} 10 0000 0000 0000 0000 0000 0000 0000
140@end example 141@end example
141 142
142 Many of the functions described in this chapter accept markers for 143 Many of the functions described in this chapter accept markers for
@@ -820,19 +821,19 @@ value of a positive integer by two, rounding downward.
820The function @code{lsh}, like all Emacs Lisp arithmetic functions, does 821The function @code{lsh}, like all Emacs Lisp arithmetic functions, does
821not check for overflow, so shifting left can discard significant bits 822not check for overflow, so shifting left can discard significant bits
822and change the sign of the number. For example, left shifting 823and change the sign of the number. For example, left shifting
823268,435,455 produces @minus{}2 on a 29-bit machine: 824536,870,911 produces @minus{}2 on a 30-bit machine:
824 825
825@example 826@example
826(lsh 268435455 1) ; @r{left shift} 827(lsh 536870911 1) ; @r{left shift}
827 @result{} -2 828 @result{} -2
828@end example 829@end example
829 830
830In binary, in the 29-bit implementation, the argument looks like this: 831In binary, in the 30-bit implementation, the argument looks like this:
831 832
832@example 833@example
833@group 834@group
834;; @r{Decimal 268,435,455} 835;; @r{Decimal 536,870,911}
8350 1111 1111 1111 1111 1111 1111 1111 83601 1111 1111 1111 1111 1111 1111 1111
836@end group 837@end group
837@end example 838@end example
838 839
@@ -842,7 +843,7 @@ which becomes the following when left shifted:
842@example 843@example
843@group 844@group
844;; @r{Decimal @minus{}2} 845;; @r{Decimal @minus{}2}
8451 1111 1111 1111 1111 1111 1111 1110 84611 1111 1111 1111 1111 1111 1111 1110
846@end group 847@end group
847@end example 848@end example
848@end defun 849@end defun
@@ -865,9 +866,9 @@ looks like this:
865@group 866@group
866(ash -6 -1) @result{} -3 867(ash -6 -1) @result{} -3
867;; @r{Decimal @minus{}6 becomes decimal @minus{}3.} 868;; @r{Decimal @minus{}6 becomes decimal @minus{}3.}
8681 1111 1111 1111 1111 1111 1111 1010 86911 1111 1111 1111 1111 1111 1111 1010
869 @result{} 870 @result{}
8701 1111 1111 1111 1111 1111 1111 1101 87111 1111 1111 1111 1111 1111 1111 1101
871@end group 872@end group
872@end example 873@end example
873 874
@@ -876,11 +877,11 @@ In contrast, shifting the pattern of bits one place to the right with
876 877
877@example 878@example
878@group 879@group
879(lsh -6 -1) @result{} 268435453 880(lsh -6 -1) @result{} 536870909
880;; @r{Decimal @minus{}6 becomes decimal 268,435,453.} 881;; @r{Decimal @minus{}6 becomes decimal 536,870,909.}
8811 1111 1111 1111 1111 1111 1111 1010 88211 1111 1111 1111 1111 1111 1111 1010
882 @result{} 883 @result{}
8830 1111 1111 1111 1111 1111 1111 1101 88401 1111 1111 1111 1111 1111 1111 1101
884@end group 885@end group
885@end example 886@end example
886 887
@@ -890,34 +891,34 @@ Here are other examples:
890@c with smallbook but not with regular book! --rjc 16mar92 891@c with smallbook but not with regular book! --rjc 16mar92
891@smallexample 892@smallexample
892@group 893@group
893 ; @r{ 29-bit binary values} 894 ; @r{ 30-bit binary values}
894 895
895(lsh 5 2) ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 896(lsh 5 2) ; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
896 @result{} 20 ; = @r{0 0000 0000 0000 0000 0000 0001 0100} 897 @result{} 20 ; = @r{00 0000 0000 0000 0000 0000 0001 0100}
897@end group 898@end group
898@group 899@group
899(ash 5 2) 900(ash 5 2)
900 @result{} 20 901 @result{} 20
901(lsh -5 2) ; -5 = @r{1 1111 1111 1111 1111 1111 1111 1011} 902(lsh -5 2) ; -5 = @r{11 1111 1111 1111 1111 1111 1111 1011}
902 @result{} -20 ; = @r{1 1111 1111 1111 1111 1111 1110 1100} 903 @result{} -20 ; = @r{11 1111 1111 1111 1111 1111 1110 1100}
903(ash -5 2) 904(ash -5 2)
904 @result{} -20 905 @result{} -20
905@end group 906@end group
906@group 907@group
907(lsh 5 -2) ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 908(lsh 5 -2) ; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
908 @result{} 1 ; = @r{0 0000 0000 0000 0000 0000 0000 0001} 909 @result{} 1 ; = @r{00 0000 0000 0000 0000 0000 0000 0001}
909@end group 910@end group
910@group 911@group
911(ash 5 -2) 912(ash 5 -2)
912 @result{} 1 913 @result{} 1
913@end group 914@end group
914@group 915@group
915(lsh -5 -2) ; -5 = @r{1 1111 1111 1111 1111 1111 1111 1011} 916(lsh -5 -2) ; -5 = @r{11 1111 1111 1111 1111 1111 1111 1011}
916 @result{} 134217726 ; = @r{0 0111 1111 1111 1111 1111 1111 1110} 917 @result{} 268435454 ; = @r{00 0111 1111 1111 1111 1111 1111 1110}
917@end group 918@end group
918@group 919@group
919(ash -5 -2) ; -5 = @r{1 1111 1111 1111 1111 1111 1111 1011} 920(ash -5 -2) ; -5 = @r{11 1111 1111 1111 1111 1111 1111 1011}
920 @result{} -2 ; = @r{1 1111 1111 1111 1111 1111 1111 1110} 921 @result{} -2 ; = @r{11 1111 1111 1111 1111 1111 1111 1110}
921@end group 922@end group
922@end smallexample 923@end smallexample
923@end defun 924@end defun
@@ -952,23 +953,23 @@ because its binary representation consists entirely of ones. If
952 953
953@smallexample 954@smallexample
954@group 955@group
955 ; @r{ 29-bit binary values} 956 ; @r{ 30-bit binary values}
956 957
957(logand 14 13) ; 14 = @r{0 0000 0000 0000 0000 0000 0000 1110} 958(logand 14 13) ; 14 = @r{00 0000 0000 0000 0000 0000 0000 1110}
958 ; 13 = @r{0 0000 0000 0000 0000 0000 0000 1101} 959 ; 13 = @r{00 0000 0000 0000 0000 0000 0000 1101}
959 @result{} 12 ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} 960 @result{} 12 ; 12 = @r{00 0000 0000 0000 0000 0000 0000 1100}
960@end group 961@end group
961 962
962@group 963@group
963(logand 14 13 4) ; 14 = @r{0 0000 0000 0000 0000 0000 0000 1110} 964(logand 14 13 4) ; 14 = @r{00 0000 0000 0000 0000 0000 0000 1110}
964 ; 13 = @r{0 0000 0000 0000 0000 0000 0000 1101} 965 ; 13 = @r{00 0000 0000 0000 0000 0000 0000 1101}
965 ; 4 = @r{0 0000 0000 0000 0000 0000 0000 0100} 966 ; 4 = @r{00 0000 0000 0000 0000 0000 0000 0100}
966 @result{} 4 ; 4 = @r{0 0000 0000 0000 0000 0000 0000 0100} 967 @result{} 4 ; 4 = @r{00 0000 0000 0000 0000 0000 0000 0100}
967@end group 968@end group
968 969
969@group 970@group
970(logand) 971(logand)
971 @result{} -1 ; -1 = @r{1 1111 1111 1111 1111 1111 1111 1111} 972 @result{} -1 ; -1 = @r{11 1111 1111 1111 1111 1111 1111 1111}
972@end group 973@end group
973@end smallexample 974@end smallexample
974@end defun 975@end defun
@@ -982,18 +983,18 @@ passed just one argument, it returns that argument.
982 983
983@smallexample 984@smallexample
984@group 985@group
985 ; @r{ 29-bit binary values} 986 ; @r{ 30-bit binary values}
986 987
987(logior 12 5) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} 988(logior 12 5) ; 12 = @r{00 0000 0000 0000 0000 0000 0000 1100}
988 ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 989 ; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
989 @result{} 13 ; 13 = @r{0 0000 0000 0000 0000 0000 0000 1101} 990 @result{} 13 ; 13 = @r{00 0000 0000 0000 0000 0000 0000 1101}
990@end group 991@end group
991 992
992@group 993@group
993(logior 12 5 7) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} 994(logior 12 5 7) ; 12 = @r{00 0000 0000 0000 0000 0000 0000 1100}
994 ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 995 ; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
995 ; 7 = @r{0 0000 0000 0000 0000 0000 0000 0111} 996 ; 7 = @r{00 0000 0000 0000 0000 0000 0000 0111}
996 @result{} 15 ; 15 = @r{0 0000 0000 0000 0000 0000 0000 1111} 997 @result{} 15 ; 15 = @r{00 0000 0000 0000 0000 0000 0000 1111}
997@end group 998@end group
998@end smallexample 999@end smallexample
999@end defun 1000@end defun
@@ -1007,18 +1008,18 @@ result is 0, which is an identity element for this operation. If
1007 1008
1008@smallexample 1009@smallexample
1009@group 1010@group
1010 ; @r{ 29-bit binary values} 1011 ; @r{ 30-bit binary values}
1011 1012
1012(logxor 12 5) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} 1013(logxor 12 5) ; 12 = @r{00 0000 0000 0000 0000 0000 0000 1100}
1013 ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 1014 ; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
1014 @result{} 9 ; 9 = @r{0 0000 0000 0000 0000 0000 0000 1001} 1015 @result{} 9 ; 9 = @r{00 0000 0000 0000 0000 0000 0000 1001}
1015@end group 1016@end group
1016 1017
1017@group 1018@group
1018(logxor 12 5 7) ; 12 = @r{0 0000 0000 0000 0000 0000 0000 1100} 1019(logxor 12 5 7) ; 12 = @r{00 0000 0000 0000 0000 0000 0000 1100}
1019 ; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 1020 ; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
1020 ; 7 = @r{0 0000 0000 0000 0000 0000 0000 0111} 1021 ; 7 = @r{00 0000 0000 0000 0000 0000 0000 0111}
1021 @result{} 14 ; 14 = @r{0 0000 0000 0000 0000 0000 0000 1110} 1022 @result{} 14 ; 14 = @r{00 0000 0000 0000 0000 0000 0000 1110}
1022@end group 1023@end group
1023@end smallexample 1024@end smallexample
1024@end defun 1025@end defun
@@ -1031,9 +1032,9 @@ bit is one in the result if, and only if, the @var{n}th bit is zero in
1031@example 1032@example
1032(lognot 5) 1033(lognot 5)
1033 @result{} -6 1034 @result{} -6
1034;; 5 = @r{0 0000 0000 0000 0000 0000 0000 0101} 1035;; 5 = @r{00 0000 0000 0000 0000 0000 0000 0101}
1035;; @r{becomes} 1036;; @r{becomes}
1036;; -6 = @r{1 1111 1111 1111 1111 1111 1111 1010} 1037;; -6 = @r{11 1111 1111 1111 1111 1111 1111 1010}
1037@end example 1038@end example
1038@end defun 1039@end defun
1039 1040
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index d6e84ee2cca..26c17f09f0e 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -165,24 +165,24 @@ latter are unique to Emacs Lisp.
165@node Integer Type 165@node Integer Type
166@subsection Integer Type 166@subsection Integer Type
167 167
168 The range of values for integers in Emacs Lisp is @minus{}268435456 to 168 The range of values for integers in Emacs Lisp is @minus{}536870912 to
169268435455 (29 bits; i.e., 169536870911 (30 bits; i.e.,
170@ifnottex 170@ifnottex
171-2**28 171-2**29
172@end ifnottex 172@end ifnottex
173@tex 173@tex
174@math{-2^{28}} 174@math{-2^{29}}
175@end tex 175@end tex
176to 176to
177@ifnottex 177@ifnottex
1782**28 - 1) 1782**29 - 1)
179@end ifnottex 179@end ifnottex
180@tex 180@tex
181@math{2^{28}-1}) 181@math{2^{29}-1})
182@end tex 182@end tex
183on most machines. (Some machines may provide a wider range.) It is 183on most machines. (Some machines may provide a wider range.) It is
184important to note that the Emacs Lisp arithmetic functions do not check 184important to note that the Emacs Lisp arithmetic functions do not check
185for overflow. Thus @code{(1+ 268435455)} is @minus{}268435456 on most 185for overflow. Thus @code{(1+ 536870911)} is @minus{}536870912 on most
186machines. 186machines.
187 187
188 The read syntax for integers is a sequence of (base ten) digits with an 188 The read syntax for integers is a sequence of (base ten) digits with an
@@ -196,7 +196,7 @@ leading @samp{+} or a final @samp{.}.
1961 ; @r{The integer 1.} 1961 ; @r{The integer 1.}
1971. ; @r{Also the integer 1.} 1971. ; @r{Also the integer 1.}
198+1 ; @r{Also the integer 1.} 198+1 ; @r{Also the integer 1.}
199536870913 ; @r{Also the integer 1 on a 29-bit implementation.} 1991073741825 ; @r{Also the integer 1 on a 30-bit implementation.}
200@end group 200@end group
201@end example 201@end example
202 202