aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-04-26 20:24:51 +0000
committerRichard M. Stallman1994-04-26 20:24:51 +0000
commit05fd2b657637064d8a7ac7d0f55642c7a6d819df (patch)
treee8791d345b9a75487ca9cc00a5837428addd9305
parent7791402edc21aed4f73894d1dbe2b2718a1cfb6f (diff)
downloademacs-05fd2b657637064d8a7ac7d0f55642c7a6d819df.tar.gz
emacs-05fd2b657637064d8a7ac7d0f55642c7a6d819df.zip
*** empty log message ***
-rw-r--r--lispref/functions.texi2
-rw-r--r--lispref/numbers.texi148
-rw-r--r--lispref/processes.texi6
-rw-r--r--lispref/streams.texi4
4 files changed, 75 insertions, 85 deletions
diff --git a/lispref/functions.texi b/lispref/functions.texi
index fbcbc64180f..3897d02c06a 100644
--- a/lispref/functions.texi
+++ b/lispref/functions.texi
@@ -450,7 +450,7 @@ equally well a name for the same function.
450these two uses of a symbol are independent and do not conflict. 450these two uses of a symbol are independent and do not conflict.
451 451
452@node Defining Functions 452@node Defining Functions
453@section Defining Named Functions 453@section Defining Functions
454@cindex defining a function 454@cindex defining a function
455 455
456 We usually give a name to a function when it is first created. This 456 We usually give a name to a function when it is first created. This
diff --git a/lispref/numbers.texi b/lispref/numbers.texi
index f2e0a7df07a..e3456efbb20 100644
--- a/lispref/numbers.texi
+++ b/lispref/numbers.texi
@@ -3,7 +3,7 @@
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4@c See the file elisp.texi for copying conditions. 4@c See the file elisp.texi for copying conditions.
5@setfilename ../info/numbers 5@setfilename ../info/numbers
6@node Numbers, Strings and Characters, Types of Lisp Object, Top 6@node Numbers, Strings and Characters, Lisp Data Types, Top
7@chapter Numbers 7@chapter Numbers
8@cindex integers 8@cindex integers
9@cindex numbers 9@cindex numbers
@@ -12,8 +12,8 @@
12@dfn{floating point numbers}. Integers are whole numbers such as 12@dfn{floating point numbers}. Integers are whole numbers such as
13@minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point 13@minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point
14numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or 14numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or
152.71828. They can also be expressed in an exponential notation as well: 152.71828. They can also be expressed in exponential notation:
16thus, 1.5e2 equals 150; in this example, @samp{e2} stands for ten to the 161.5e2 equals 150; in this example, @samp{e2} stands for ten to the
17second power, and is multiplied by 1.5. Floating point values are not 17second power, and is multiplied by 1.5. Floating point values are not
18exact; they have a fixed, limited amount of precision. 18exact; they have a fixed, limited amount of precision.
19 19
@@ -75,7 +75,7 @@ initial sign and optional final period.
75bitwise operators (@pxref{Bitwise Operations}), it is often helpful to 75bitwise operators (@pxref{Bitwise Operations}), it is often helpful to
76view the numbers in their binary form. 76view the numbers in their binary form.
77 77
78 In 24 bit binary, the decimal integer 5 looks like this: 78 In 24-bit binary, the decimal integer 5 looks like this:
79 79
80@example 80@example
810000 0000 0000 0000 0000 0101 810000 0000 0000 0000 0000 0101
@@ -104,7 +104,7 @@ complement} notation.)
1041111 1111 1111 1111 1111 1011 1041111 1111 1111 1111 1111 1011
105@end example 105@end example
106 106
107 In this implementation, the largest 24 bit binary integer is the 107 In this implementation, the largest 24-bit binary integer is the
108decimal integer 8,388,607. In binary, it looks like this: 108decimal integer 8,388,607. In binary, it looks like this:
109 109
110@example 110@example
@@ -112,8 +112,8 @@ decimal integer 8,388,607. In binary, it looks like this:
112@end example 112@end example
113 113
114 Since the arithmetic functions do not check whether integers go 114 Since the arithmetic functions do not check whether integers go
115outside their range, when you add 1 to 8,388,607, the value is negative 115outside their range, when you add 1 to 8,388,607, the value is the
116integer @minus{}8,388,608: 116negative integer @minus{}8,388,608:
117 117
118@example 118@example
119(+ 1 8388607) 119(+ 1 8388607)
@@ -157,11 +157,14 @@ a minus sign to write negative floating point numbers, as in
157@cindex NaN 157@cindex NaN
158 Most modern computers support the IEEE floating point standard, which 158 Most modern computers support the IEEE floating point standard, which
159provides for positive infinity and negative infinity as floating point 159provides for positive infinity and negative infinity as floating point
160values. It also provides for a value called NaN or ``not-a-number'' 160values. It also provides for a class of values called NaN or
161which is the result you get from numerical functions in cases where 161``not-a-number''; numerical functions return such values in cases where
162there is no correct answer. For example, @code{(sqrt -1.0)} returns 162there is no correct answer. For example, @code{(sqrt -1.0)} returns a
163NaN. There is no read syntax for NaN or infinities; perhaps we should 163NaN. For practical purposes, there's no significant difference between
164create a syntax in the future. 164different NaN values in Emacs Lisp, and there's no rule for precisely
165which NaN value should be used in a particular case, so this manual
166doesn't try to distinguish them. Emacs Lisp has no read syntax for NaNs
167or infinities; perhaps we should create a syntax in the future.
165 168
166 You can use @code{logb} to extract the binary exponent of a floating 169 You can use @code{logb} to extract the binary exponent of a floating
167point number (or estimate the logarithm of an integer): 170point number (or estimate the logarithm of an integer):
@@ -200,19 +203,15 @@ This predicate tests whether its argument is a number (either integer or
200floating point), and returns @code{t} if so, @code{nil} otherwise. 203floating point), and returns @code{t} if so, @code{nil} otherwise.
201@end defun 204@end defun
202 205
203@defun natnump object 206@defun wholenump object
204@cindex natural numbers 207@cindex natural numbers
205The @code{natnump} predicate (whose name comes from the phrase 208The @code{wholenump} predicate (whose name comes from the phrase
206``natural-number-p'') tests to see whether its argument is a nonnegative 209``whole-number-p'') tests to see whether its argument is a nonnegative
207integer, and returns @code{t} if so, @code{nil} otherwise. 0 is 210integer, and returns @code{t} if so, @code{nil} otherwise. 0 is
208considered non-negative. 211considered non-negative.
209 212
210Markers are not converted to integers, hence @code{natnump} of a marker 213@findex natnump
211is always @code{nil}. 214@code{natnump} is an obsolete synonym for @code{wholenump}.
212
213People have pointed out that this function is misnamed, because the term
214``natural number'' is usually understood as excluding zero. We are open
215to suggestions for a better name to use in a future version.
216@end defun 215@end defun
217 216
218@defun zerop number 217@defun zerop number
@@ -226,19 +225,22 @@ These two forms are equivalent: @code{(zerop x)} @equiv{} @code{(= x 0)}.
226@section Comparison of Numbers 225@section Comparison of Numbers
227@cindex number equality 226@cindex number equality
228 227
229 Floating point numbers in Emacs Lisp actually take up storage, and 228 To test numbers for numerical equality, you should normally use
230there can be many distinct floating point number objects with the same 229@code{=}, not @code{eq}. There can be many distinct floating point
231numeric value. If you use @code{eq} to compare them, then you test 230number objects with the same numeric value. If you use @code{eq} to
232whether two values are the same @emph{object}. If you want to test for 231compare them, then you test whether two values are the same
233numerical equality, use @code{=}. 232@emph{object}. By contrast, @code{=} compares only the numeric values
234 233of the objects.
235 If you use @code{eq} to compare two integers, it always returns 234
236@code{t} if they have the same value. This is sometimes useful, because 235 At present, each integer value has a unique Lisp object in Emacs Lisp.
237@code{eq} accepts arguments of any type and never causes an error, 236Therefore, @code{eq} is equivalent @code{=} where integers are
238whereas @code{=} signals an error if the arguments are not numbers or 237concerned. It is sometimes convenient to use @code{eq} for comparing an
239markers. However, it is a good idea to use @code{=} if you can, even 238unknown value with an integer, because @code{eq} does not report an
240for comparing integers, just in case we change the representation of 239error if the unknown value is not a number---it accepts arguments of any
241integers in a future Emacs version. 240type. By contrast, @code{=} signals an error if the arguments are not
241numbers or markers. However, it is a good idea to use @code{=} if you
242can, even for comparing integers, just in case we change the
243representation of integers in a future Emacs version.
242 244
243 There is another wrinkle: because floating point arithmetic is not 245 There is another wrinkle: because floating point arithmetic is not
244exact, it is often a bad idea to check for equality of two floating 246exact, it is often a bad idea to check for equality of two floating
@@ -255,7 +257,7 @@ Here's a function to do this:
255 257
256@cindex CL note---integers vrs @code{eq} 258@cindex CL note---integers vrs @code{eq}
257@quotation 259@quotation
258@b{Common Lisp note:} comparing numbers in Common Lisp always requires 260@b{Common Lisp note:} Comparing numbers in Common Lisp always requires
259@code{=} because Common Lisp implements multi-word integers, and two 261@code{=} because Common Lisp implements multi-word integers, and two
260distinct integer objects can have the same numeric value. Emacs Lisp 262distinct integer objects can have the same numeric value. Emacs Lisp
261can have just one integer object for any given value because it has a 263can have just one integer object for any given value because it has a
@@ -458,7 +460,7 @@ not check for overflow.
458@end defun 460@end defun
459 461
460@defun / dividend divisor &rest divisors 462@defun / dividend divisor &rest divisors
461This function divides @var{dividend} by @var{divisors} and returns the 463This function divides @var{dividend} by @var{divisor} and returns the
462quotient. If there are additional arguments @var{divisors}, then it 464quotient. If there are additional arguments @var{divisors}, then it
463divides @var{dividend} by each divisor in turn. Each argument may be a 465divides @var{dividend} by each divisor in turn. Each argument may be a
464number or a marker. 466number or a marker.
@@ -573,7 +575,7 @@ The functions @code{ffloor}, @code{fceil}, @code{fround} and
573@code{ftruncate} take a floating point argument and return a floating 575@code{ftruncate} take a floating point argument and return a floating
574point result whose value is a nearby integer. @code{ffloor} returns the 576point result whose value is a nearby integer. @code{ffloor} returns the
575nearest integer below; @code{fceil}, the nearest integer above; 577nearest integer below; @code{fceil}, the nearest integer above;
576@code{ftrucate}, the nearest integer in the direction towards zero; 578@code{ftruncate}, the nearest integer in the direction towards zero;
577@code{fround}, the nearest integer. 579@code{fround}, the nearest integer.
578 580
579@defun ffloor float 581@defun ffloor float
@@ -586,7 +588,7 @@ This function rounds @var{float} to the next higher integral value, and
586returns that value as a floating point number. 588returns that value as a floating point number.
587@end defun 589@end defun
588 590
589@defun ftrunc float 591@defun ftruncate float
590This function rounds @var{float} towards zero to an integral value, and 592This function rounds @var{float} towards zero to an integral value, and
591returns that value as a floating point number. 593returns that value as a floating point number.
592@end defun 594@end defun
@@ -610,22 +612,15 @@ reproducing the same pattern ``moved over''.
610@defun lsh integer1 count 612@defun lsh integer1 count
611@cindex logical shift 613@cindex logical shift
612@code{lsh}, which is an abbreviation for @dfn{logical shift}, shifts the 614@code{lsh}, which is an abbreviation for @dfn{logical shift}, shifts the
613bits in @var{integer1} to the left @var{count} places, or to the 615bits in @var{integer1} to the left @var{count} places, or to the right
614right if @var{count} is negative. If @var{count} is negative, 616if @var{count} is negative, bringing zeros into the vacated bits. If
615@code{lsh} shifts zeros into the most-significant bit, producing a 617@var{count} is negative, @code{lsh} shifts zeros into the leftmost
616positive result even if @var{integer1} is negative. Contrast this with 618(most-significant) bit, producing a positive result even if
617@code{ash}, below. 619@var{integer1} is negative. Contrast this with @code{ash}, below.
618 620
619Thus, the decimal number 5 is the binary number 00000101. Shifted once 621Here are two examples of @code{lsh}, shifting a pattern of bits one
620to the left, with a zero put in the one's place, the number becomes 622place to the left. We show only the low-order eight bits of the binary
62100001010, decimal 10. 623pattern; the rest are all zero.
622
623Here are two examples of shifting the pattern of bits one place to the
624left. Since the contents of the rightmost place has been moved one
625place to the left, a value has to be inserted into the rightmost place.
626With @code{lsh}, a zero is placed into the rightmost place. (These
627examples show only the low-order eight bits of the binary pattern; the
628rest are all zero.)
629 624
630@example 625@example
631@group 626@group
@@ -646,18 +641,17 @@ As the examples illustrate, shifting the pattern of bits one place to
646the left produces a number that is twice the value of the previous 641the left produces a number that is twice the value of the previous
647number. 642number.
648 643
649Note, however that functions do not check for overflow, and a returned 644The function @code{lsh}, like all Emacs Lisp arithmetic functions, does
650value may be negative (and in any case, no more than a 24 bit value) 645not check for overflow, so shifting left can discard significant bits
651when an integer is sufficiently left shifted. 646and change the sign of the number. For example, left shifting 8,388,607
652 647produces @minus{}2 on a 24-bit machine:
653For example, left shifting 8,388,607 produces @minus{}2:
654 648
655@example 649@example
656(lsh 8388607 1) ; @r{left shift} 650(lsh 8388607 1) ; @r{left shift}
657 @result{} -2 651 @result{} -2
658@end example 652@end example
659 653
660In binary, in the 24 bit implementation, the numbers looks like this: 654In binary, in the 24-bit implementation, the argument looks like this:
661 655
662@example 656@example
663@group 657@group
@@ -749,10 +743,6 @@ In contrast, shifting the pattern of bits one place to the right with
749@end group 743@end group
750@end example 744@end example
751 745
752@noindent
753In this case, the 1 in the leftmost position is shifted one place to the
754right, and a zero is shifted into the leftmost position.
755
756Here are other examples: 746Here are other examples:
757 747
758@c !!! Check if lined up in smallbook format! XDVI shows problem 748@c !!! Check if lined up in smallbook format! XDVI shows problem
@@ -762,19 +752,19 @@ Here are other examples:
762 ; @r{ 24-bit binary values} 752 ; @r{ 24-bit binary values}
763 753
764(lsh 5 2) ; 5 = @r{0000 0000 0000 0000 0000 0101} 754(lsh 5 2) ; 5 = @r{0000 0000 0000 0000 0000 0101}
765 @result{} 20 ; 20 = @r{0000 0000 0000 0000 0001 0100} 755 @result{} 20 ; = @r{0000 0000 0000 0000 0001 0100}
766@end group 756@end group
767@group 757@group
768(ash 5 2) 758(ash 5 2)
769 @result{} 20 759 @result{} 20
770(lsh -5 2) ; -5 = @r{1111 1111 1111 1111 1111 1011} 760(lsh -5 2) ; -5 = @r{1111 1111 1111 1111 1111 1011}
771 @result{} -20 ; -20 = @r{1111 1111 1111 1111 1110 1100} 761 @result{} -20 ; = @r{1111 1111 1111 1111 1110 1100}
772(ash -5 2) 762(ash -5 2)
773 @result{} -20 763 @result{} -20
774@end group 764@end group
775@group 765@group
776(lsh 5 -2) ; 5 = @r{0000 0000 0000 0000 0000 0101} 766(lsh 5 -2) ; 5 = @r{0000 0000 0000 0000 0000 0101}
777 @result{} 1 ; 1 = @r{0000 0000 0000 0000 0000 0001} 767 @result{} 1 ; = @r{0000 0000 0000 0000 0000 0001}
778@end group 768@end group
779@group 769@group
780(ash 5 -2) 770(ash 5 -2)
@@ -782,11 +772,11 @@ Here are other examples:
782@end group 772@end group
783@group 773@group
784(lsh -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011} 774(lsh -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011}
785 @result{} 4194302 ; @r{0011 1111 1111 1111 1111 1110} 775 @result{} 4194302 ; = @r{0011 1111 1111 1111 1111 1110}
786@end group 776@end group
787@group 777@group
788(ash -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011} 778(ash -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011}
789 @result{} -2 ; -2 = @r{1111 1111 1111 1111 1111 1110} 779 @result{} -2 ; = @r{1111 1111 1111 1111 1111 1110}
790@end group 780@end group
791@end smallexample 781@end smallexample
792@end defun 782@end defun
@@ -801,7 +791,6 @@ rather than 0.)
801 791
802For example, using 4-bit binary numbers, the ``logical and'' of 13 and 792For example, using 4-bit binary numbers, the ``logical and'' of 13 and
80312 is 12: 1101 combined with 1100 produces 1100. 79312 is 12: 1101 combined with 1100 produces 1100.
804
805In both the binary numbers, the leftmost two bits are set (i.e., they 794In both the binary numbers, the leftmost two bits are set (i.e., they
806are 1's), so the leftmost two bits of the returned value are set. 795are 1's), so the leftmost two bits of the returned value are set.
807However, for the rightmost two bits, each is zero in at least one of 796However, for the rightmost two bits, each is zero in at least one of
@@ -876,10 +865,10 @@ passed just one argument, it returns that argument.
876@cindex bitwise exclusive or 865@cindex bitwise exclusive or
877@cindex logical exclusive or 866@cindex logical exclusive or
878This function returns the ``exclusive or'' of its arguments: the 867This function returns the ``exclusive or'' of its arguments: the
879@var{n}th bit is set in the result if, and only if, the @var{n}th bit 868@var{n}th bit is set in the result if, and only if, the @var{n}th bit is
880is set in an odd number of the arguments. If there are no arguments, 869set in an odd number of the arguments. If there are no arguments, the
881the result is 0. If @code{logxor} is passed just one argument, it returns 870result is 0, which is an identity element for this operation. If
882that argument. 871@code{logxor} is passed just one argument, it returns that argument.
883 872
884@smallexample 873@smallexample
885@group 874@group
@@ -932,8 +921,8 @@ in radians.
932@end defun 921@end defun
933 922
934@defun asin arg 923@defun asin arg
935The value of @code{(asin @var{arg})} is a number between @minus{} pi / 2 924The value of @code{(asin @var{arg})} is a number between @minus{}pi/2
936and pi / 2 (inclusive) whose sine is @var{arg}; if, however, @var{arg} 925and pi/2 (inclusive) whose sine is @var{arg}; if, however, @var{arg}
937is out of range (outside [-1, 1]), then the result is a NaN. 926is out of range (outside [-1, 1]), then the result is a NaN.
938@end defun 927@end defun
939 928
@@ -944,8 +933,8 @@ is out of range (outside [-1, 1]), then the result is a NaN.
944@end defun 933@end defun
945 934
946@defun atan arg 935@defun atan arg
947The value of @code{(atan @var{arg})} is a number between @minus{} pi / 2 936The value of @code{(atan @var{arg})} is a number between @minus{}pi/2
948and pi / 2 (exclusive) whose tangent is @var{arg}. 937and pi/2 (exclusive) whose tangent is @var{arg}.
949@end defun 938@end defun
950 939
951@defun exp arg 940@defun exp arg
@@ -976,7 +965,8 @@ lose accuracy.
976 965
977@defun log10 arg 966@defun log10 arg
978This function returns the logarithm of @var{arg}, with base 10. If 967This function returns the logarithm of @var{arg}, with base 10. If
979@var{arg} is negative, the result is a NaN. 968@var{arg} is negative, the result is a NaN. @code{(log10 @var{x})}
969@equiv{} @code{(log @var{x} 10)}, at least approximately.
980@end defun 970@end defun
981 971
982@defun expt x y 972@defun expt x y
diff --git a/lispref/processes.texi b/lispref/processes.texi
index d4479bebeae..26fd5e8be00 100644
--- a/lispref/processes.texi
+++ b/lispref/processes.texi
@@ -80,9 +80,9 @@ Expansion}).
80argument which specifies where the standard output from the program will 80argument which specifies where the standard output from the program will
81go. If @var{buffer-or-name} is @code{nil}, that says to discard the 81go. If @var{buffer-or-name} is @code{nil}, that says to discard the
82output unless a filter function handles it. (@xref{Filter Functions}, 82output unless a filter function handles it. (@xref{Filter Functions},
83and @ref{Streams}.) Normally, you should avoid having multiple 83and @ref{Streams, Reading and Printing}.) Normally, you should avoid
84processes send output to the same buffer because their output would be 84having multiple processes send output to the same buffer because their
85intermixed randomly. 85output would be intermixed randomly.
86 86
87@cindex program arguments 87@cindex program arguments
88 All three of the subprocess-creating functions have a @code{&rest} 88 All three of the subprocess-creating functions have a @code{&rest}
diff --git a/lispref/streams.texi b/lispref/streams.texi
index af3787f579d..22c9c89ae33 100644
--- a/lispref/streams.texi
+++ b/lispref/streams.texi
@@ -3,13 +3,13 @@
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4@c See the file elisp.texi for copying conditions. 4@c See the file elisp.texi for copying conditions.
5@setfilename ../info/streams 5@setfilename ../info/streams
6@node Streams, Minibuffers, Debugging, Top 6@node Read and Print, Minibuffers, Debugging, Top
7@comment node-name, next, previous, up 7@comment node-name, next, previous, up
8@chapter Reading and Printing Lisp Objects 8@chapter Reading and Printing Lisp Objects
9 9
10 @dfn{Printing} and @dfn{reading} are the operations of converting Lisp 10 @dfn{Printing} and @dfn{reading} are the operations of converting Lisp
11objects to textual form and vice versa. They use the printed 11objects to textual form and vice versa. They use the printed
12representations and read syntax described in @ref{Types of Lisp Object}. 12representations and read syntax described in @ref{Lisp Data Types}.
13 13
14 This chapter describes the Lisp functions for reading and printing. 14 This chapter describes the Lisp functions for reading and printing.
15It also describes @dfn{streams}, which specify where to get the text (if 15It also describes @dfn{streams}, which specify where to get the text (if