1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-02-02 20:16:25 +00:00

*** empty log message ***

This commit is contained in:
Richard M. Stallman 1994-04-26 20:24:51 +00:00
parent 7791402edc
commit 05fd2b6576
4 changed files with 73 additions and 83 deletions

View File

@ -450,7 +450,7 @@ equally well a name for the same function.
these two uses of a symbol are independent and do not conflict. these two uses of a symbol are independent and do not conflict.
@node Defining Functions @node Defining Functions
@section Defining Named Functions @section Defining Functions
@cindex defining a function @cindex defining a function
We usually give a name to a function when it is first created. This We usually give a name to a function when it is first created. This

View File

@ -3,7 +3,7 @@
@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions. @c See the file elisp.texi for copying conditions.
@setfilename ../info/numbers @setfilename ../info/numbers
@node Numbers, Strings and Characters, Types of Lisp Object, Top @node Numbers, Strings and Characters, Lisp Data Types, Top
@chapter Numbers @chapter Numbers
@cindex integers @cindex integers
@cindex numbers @cindex numbers
@ -12,8 +12,8 @@
@dfn{floating point numbers}. Integers are whole numbers such as @dfn{floating point numbers}. Integers are whole numbers such as
@minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point @minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point
numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or
2.71828. They can also be expressed in an exponential notation as well: 2.71828. They can also be expressed in exponential notation:
thus, 1.5e2 equals 150; in this example, @samp{e2} stands for ten to the 1.5e2 equals 150; in this example, @samp{e2} stands for ten to the
second power, and is multiplied by 1.5. Floating point values are not second power, and is multiplied by 1.5. Floating point values are not
exact; they have a fixed, limited amount of precision. exact; they have a fixed, limited amount of precision.
@ -75,7 +75,7 @@ initial sign and optional final period.
bitwise operators (@pxref{Bitwise Operations}), it is often helpful to bitwise operators (@pxref{Bitwise Operations}), it is often helpful to
view the numbers in their binary form. view the numbers in their binary form.
In 24 bit binary, the decimal integer 5 looks like this: In 24-bit binary, the decimal integer 5 looks like this:
@example @example
0000 0000 0000 0000 0000 0101 0000 0000 0000 0000 0000 0101
@ -104,7 +104,7 @@ complement} notation.)
1111 1111 1111 1111 1111 1011 1111 1111 1111 1111 1111 1011
@end example @end example
In this implementation, the largest 24 bit binary integer is the In this implementation, the largest 24-bit binary integer is the
decimal integer 8,388,607. In binary, it looks like this: decimal integer 8,388,607. In binary, it looks like this:
@example @example
@ -112,8 +112,8 @@ decimal integer 8,388,607. In binary, it looks like this:
@end example @end example
Since the arithmetic functions do not check whether integers go Since the arithmetic functions do not check whether integers go
outside their range, when you add 1 to 8,388,607, the value is negative outside their range, when you add 1 to 8,388,607, the value is the
integer @minus{}8,388,608: negative integer @minus{}8,388,608:
@example @example
(+ 1 8388607) (+ 1 8388607)
@ -157,11 +157,14 @@ a minus sign to write negative floating point numbers, as in
@cindex NaN @cindex NaN
Most modern computers support the IEEE floating point standard, which Most modern computers support the IEEE floating point standard, which
provides for positive infinity and negative infinity as floating point provides for positive infinity and negative infinity as floating point
values. It also provides for a value called NaN or ``not-a-number'' values. It also provides for a class of values called NaN or
which is the result you get from numerical functions in cases where ``not-a-number''; numerical functions return such values in cases where
there is no correct answer. For example, @code{(sqrt -1.0)} returns there is no correct answer. For example, @code{(sqrt -1.0)} returns a
NaN. There is no read syntax for NaN or infinities; perhaps we should NaN. For practical purposes, there's no significant difference between
create a syntax in the future. different NaN values in Emacs Lisp, and there's no rule for precisely
which NaN value should be used in a particular case, so this manual
doesn't try to distinguish them. Emacs Lisp has no read syntax for NaNs
or infinities; perhaps we should create a syntax in the future.
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
point number (or estimate the logarithm of an integer): point number (or estimate the logarithm of an integer):
@ -200,19 +203,15 @@ This predicate tests whether its argument is a number (either integer or
floating point), and returns @code{t} if so, @code{nil} otherwise. floating point), and returns @code{t} if so, @code{nil} otherwise.
@end defun @end defun
@defun natnump object @defun wholenump object
@cindex natural numbers @cindex natural numbers
The @code{natnump} predicate (whose name comes from the phrase The @code{wholenump} predicate (whose name comes from the phrase
``natural-number-p'') tests to see whether its argument is a nonnegative ``whole-number-p'') tests to see whether its argument is a nonnegative
integer, and returns @code{t} if so, @code{nil} otherwise. 0 is integer, and returns @code{t} if so, @code{nil} otherwise. 0 is
considered non-negative. considered non-negative.
Markers are not converted to integers, hence @code{natnump} of a marker @findex natnump
is always @code{nil}. @code{natnump} is an obsolete synonym for @code{wholenump}.
People have pointed out that this function is misnamed, because the term
``natural number'' is usually understood as excluding zero. We are open
to suggestions for a better name to use in a future version.
@end defun @end defun
@defun zerop number @defun zerop number
@ -226,19 +225,22 @@ These two forms are equivalent: @code{(zerop x)} @equiv{} @code{(= x 0)}.
@section Comparison of Numbers @section Comparison of Numbers
@cindex number equality @cindex number equality
Floating point numbers in Emacs Lisp actually take up storage, and To test numbers for numerical equality, you should normally use
there can be many distinct floating point number objects with the same @code{=}, not @code{eq}. There can be many distinct floating point
numeric value. If you use @code{eq} to compare them, then you test number objects with the same numeric value. If you use @code{eq} to
whether two values are the same @emph{object}. If you want to test for compare them, then you test whether two values are the same
numerical equality, use @code{=}. @emph{object}. By contrast, @code{=} compares only the numeric values
of the objects.
If you use @code{eq} to compare two integers, it always returns At present, each integer value has a unique Lisp object in Emacs Lisp.
@code{t} if they have the same value. This is sometimes useful, because Therefore, @code{eq} is equivalent @code{=} where integers are
@code{eq} accepts arguments of any type and never causes an error, concerned. It is sometimes convenient to use @code{eq} for comparing an
whereas @code{=} signals an error if the arguments are not numbers or unknown value with an integer, because @code{eq} does not report an
markers. However, it is a good idea to use @code{=} if you can, even error if the unknown value is not a number---it accepts arguments of any
for comparing integers, just in case we change the representation of type. By contrast, @code{=} signals an error if the arguments are not
integers in a future Emacs version. numbers or markers. However, it is a good idea to use @code{=} if you
can, even for comparing integers, just in case we change the
representation of integers in a future Emacs version.
There is another wrinkle: because floating point arithmetic is not There is another wrinkle: because floating point arithmetic is not
exact, it is often a bad idea to check for equality of two floating exact, it is often a bad idea to check for equality of two floating
@ -255,7 +257,7 @@ Here's a function to do this:
@cindex CL note---integers vrs @code{eq} @cindex CL note---integers vrs @code{eq}
@quotation @quotation
@b{Common Lisp note:} comparing numbers in Common Lisp always requires @b{Common Lisp note:} Comparing numbers in Common Lisp always requires
@code{=} because Common Lisp implements multi-word integers, and two @code{=} because Common Lisp implements multi-word integers, and two
distinct integer objects can have the same numeric value. Emacs Lisp distinct integer objects can have the same numeric value. Emacs Lisp
can have just one integer object for any given value because it has a can have just one integer object for any given value because it has a
@ -458,7 +460,7 @@ not check for overflow.
@end defun @end defun
@defun / dividend divisor &rest divisors @defun / dividend divisor &rest divisors
This function divides @var{dividend} by @var{divisors} and returns the This function divides @var{dividend} by @var{divisor} and returns the
quotient. If there are additional arguments @var{divisors}, then it quotient. If there are additional arguments @var{divisors}, then it
divides @var{dividend} by each divisor in turn. Each argument may be a divides @var{dividend} by each divisor in turn. Each argument may be a
number or a marker. number or a marker.
@ -573,7 +575,7 @@ The functions @code{ffloor}, @code{fceil}, @code{fround} and
@code{ftruncate} take a floating point argument and return a floating @code{ftruncate} take a floating point argument and return a floating
point result whose value is a nearby integer. @code{ffloor} returns the point result whose value is a nearby integer. @code{ffloor} returns the
nearest integer below; @code{fceil}, the nearest integer above; nearest integer below; @code{fceil}, the nearest integer above;
@code{ftrucate}, the nearest integer in the direction towards zero; @code{ftruncate}, the nearest integer in the direction towards zero;
@code{fround}, the nearest integer. @code{fround}, the nearest integer.
@defun ffloor float @defun ffloor float
@ -586,7 +588,7 @@ This function rounds @var{float} to the next higher integral value, and
returns that value as a floating point number. returns that value as a floating point number.
@end defun @end defun
@defun ftrunc float @defun ftruncate float
This function rounds @var{float} towards zero to an integral value, and This function rounds @var{float} towards zero to an integral value, and
returns that value as a floating point number. returns that value as a floating point number.
@end defun @end defun
@ -610,22 +612,15 @@ reproducing the same pattern ``moved over''.
@defun lsh integer1 count @defun lsh integer1 count
@cindex logical shift @cindex logical shift
@code{lsh}, which is an abbreviation for @dfn{logical shift}, shifts the @code{lsh}, which is an abbreviation for @dfn{logical shift}, shifts the
bits in @var{integer1} to the left @var{count} places, or to the bits in @var{integer1} to the left @var{count} places, or to the right
right if @var{count} is negative. If @var{count} is negative, if @var{count} is negative, bringing zeros into the vacated bits. If
@code{lsh} shifts zeros into the most-significant bit, producing a @var{count} is negative, @code{lsh} shifts zeros into the leftmost
positive result even if @var{integer1} is negative. Contrast this with (most-significant) bit, producing a positive result even if
@code{ash}, below. @var{integer1} is negative. Contrast this with @code{ash}, below.
Thus, the decimal number 5 is the binary number 00000101. Shifted once Here are two examples of @code{lsh}, shifting a pattern of bits one
to the left, with a zero put in the one's place, the number becomes place to the left. We show only the low-order eight bits of the binary
00001010, decimal 10. pattern; the rest are all zero.
Here are two examples of shifting the pattern of bits one place to the
left. Since the contents of the rightmost place has been moved one
place to the left, a value has to be inserted into the rightmost place.
With @code{lsh}, a zero is placed into the rightmost place. (These
examples show only the low-order eight bits of the binary pattern; the
rest are all zero.)
@example @example
@group @group
@ -646,18 +641,17 @@ As the examples illustrate, shifting the pattern of bits one place to
the left produces a number that is twice the value of the previous the left produces a number that is twice the value of the previous
number. number.
Note, however that functions do not check for overflow, and a returned The function @code{lsh}, like all Emacs Lisp arithmetic functions, does
value may be negative (and in any case, no more than a 24 bit value) not check for overflow, so shifting left can discard significant bits
when an integer is sufficiently left shifted. and change the sign of the number. For example, left shifting 8,388,607
produces @minus{}2 on a 24-bit machine:
For example, left shifting 8,388,607 produces @minus{}2:
@example @example
(lsh 8388607 1) ; @r{left shift} (lsh 8388607 1) ; @r{left shift}
@result{} -2 @result{} -2
@end example @end example
In binary, in the 24 bit implementation, the numbers looks like this: In binary, in the 24-bit implementation, the argument looks like this:
@example @example
@group @group
@ -749,10 +743,6 @@ In contrast, shifting the pattern of bits one place to the right with
@end group @end group
@end example @end example
@noindent
In this case, the 1 in the leftmost position is shifted one place to the
right, and a zero is shifted into the leftmost position.
Here are other examples: Here are other examples:
@c !!! Check if lined up in smallbook format! XDVI shows problem @c !!! Check if lined up in smallbook format! XDVI shows problem
@ -762,19 +752,19 @@ Here are other examples:
; @r{ 24-bit binary values} ; @r{ 24-bit binary values}
(lsh 5 2) ; 5 = @r{0000 0000 0000 0000 0000 0101} (lsh 5 2) ; 5 = @r{0000 0000 0000 0000 0000 0101}
@result{} 20 ; 20 = @r{0000 0000 0000 0000 0001 0100} @result{} 20 ; = @r{0000 0000 0000 0000 0001 0100}
@end group @end group
@group @group
(ash 5 2) (ash 5 2)
@result{} 20 @result{} 20
(lsh -5 2) ; -5 = @r{1111 1111 1111 1111 1111 1011} (lsh -5 2) ; -5 = @r{1111 1111 1111 1111 1111 1011}
@result{} -20 ; -20 = @r{1111 1111 1111 1111 1110 1100} @result{} -20 ; = @r{1111 1111 1111 1111 1110 1100}
(ash -5 2) (ash -5 2)
@result{} -20 @result{} -20
@end group @end group
@group @group
(lsh 5 -2) ; 5 = @r{0000 0000 0000 0000 0000 0101} (lsh 5 -2) ; 5 = @r{0000 0000 0000 0000 0000 0101}
@result{} 1 ; 1 = @r{0000 0000 0000 0000 0000 0001} @result{} 1 ; = @r{0000 0000 0000 0000 0000 0001}
@end group @end group
@group @group
(ash 5 -2) (ash 5 -2)
@ -782,11 +772,11 @@ Here are other examples:
@end group @end group
@group @group
(lsh -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011} (lsh -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011}
@result{} 4194302 ; @r{0011 1111 1111 1111 1111 1110} @result{} 4194302 ; = @r{0011 1111 1111 1111 1111 1110}
@end group @end group
@group @group
(ash -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011} (ash -5 -2) ; -5 = @r{1111 1111 1111 1111 1111 1011}
@result{} -2 ; -2 = @r{1111 1111 1111 1111 1111 1110} @result{} -2 ; = @r{1111 1111 1111 1111 1111 1110}
@end group @end group
@end smallexample @end smallexample
@end defun @end defun
@ -801,7 +791,6 @@ rather than 0.)
For example, using 4-bit binary numbers, the ``logical and'' of 13 and For example, using 4-bit binary numbers, the ``logical and'' of 13 and
12 is 12: 1101 combined with 1100 produces 1100. 12 is 12: 1101 combined with 1100 produces 1100.
In both the binary numbers, the leftmost two bits are set (i.e., they In both the binary numbers, the leftmost two bits are set (i.e., they
are 1's), so the leftmost two bits of the returned value are set. are 1's), so the leftmost two bits of the returned value are set.
However, for the rightmost two bits, each is zero in at least one of However, 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.
@cindex bitwise exclusive or @cindex bitwise exclusive or
@cindex logical exclusive or @cindex logical exclusive or
This function returns the ``exclusive or'' of its arguments: the This function returns the ``exclusive or'' of its arguments: the
@var{n}th bit is set in the result if, and only if, the @var{n}th bit @var{n}th bit is set in the result if, and only if, the @var{n}th bit is
is set in an odd number of the arguments. If there are no arguments, set in an odd number of the arguments. If there are no arguments, the
the result is 0. If @code{logxor} is passed just one argument, it returns result is 0, which is an identity element for this operation. If
that argument. @code{logxor} is passed just one argument, it returns that argument.
@smallexample @smallexample
@group @group
@ -932,8 +921,8 @@ in radians.
@end defun @end defun
@defun asin arg @defun asin arg
The value of @code{(asin @var{arg})} is a number between @minus{} pi / 2 The value of @code{(asin @var{arg})} is a number between @minus{}pi/2
and pi / 2 (inclusive) whose sine is @var{arg}; if, however, @var{arg} and pi/2 (inclusive) whose sine is @var{arg}; if, however, @var{arg}
is out of range (outside [-1, 1]), then the result is a NaN. is out of range (outside [-1, 1]), then the result is a NaN.
@end defun @end defun
@ -944,8 +933,8 @@ is out of range (outside [-1, 1]), then the result is a NaN.
@end defun @end defun
@defun atan arg @defun atan arg
The value of @code{(atan @var{arg})} is a number between @minus{} pi / 2 The value of @code{(atan @var{arg})} is a number between @minus{}pi/2
and pi / 2 (exclusive) whose tangent is @var{arg}. and pi/2 (exclusive) whose tangent is @var{arg}.
@end defun @end defun
@defun exp arg @defun exp arg
@ -976,7 +965,8 @@ lose accuracy.
@defun log10 arg @defun log10 arg
This function returns the logarithm of @var{arg}, with base 10. If This function returns the logarithm of @var{arg}, with base 10. If
@var{arg} is negative, the result is a NaN. @var{arg} is negative, the result is a NaN. @code{(log10 @var{x})}
@equiv{} @code{(log @var{x} 10)}, at least approximately.
@end defun @end defun
@defun expt x y @defun expt x y

View File

@ -80,9 +80,9 @@ Expansion}).
argument which specifies where the standard output from the program will argument which specifies where the standard output from the program will
go. If @var{buffer-or-name} is @code{nil}, that says to discard the go. If @var{buffer-or-name} is @code{nil}, that says to discard the
output unless a filter function handles it. (@xref{Filter Functions}, output unless a filter function handles it. (@xref{Filter Functions},
and @ref{Streams}.) Normally, you should avoid having multiple and @ref{Streams, Reading and Printing}.) Normally, you should avoid
processes send output to the same buffer because their output would be having multiple processes send output to the same buffer because their
intermixed randomly. output would be intermixed randomly.
@cindex program arguments @cindex program arguments
All three of the subprocess-creating functions have a @code{&rest} All three of the subprocess-creating functions have a @code{&rest}

View File

@ -3,13 +3,13 @@
@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions. @c See the file elisp.texi for copying conditions.
@setfilename ../info/streams @setfilename ../info/streams
@node Streams, Minibuffers, Debugging, Top @node Read and Print, Minibuffers, Debugging, Top
@comment node-name, next, previous, up @comment node-name, next, previous, up
@chapter Reading and Printing Lisp Objects @chapter Reading and Printing Lisp Objects
@dfn{Printing} and @dfn{reading} are the operations of converting Lisp @dfn{Printing} and @dfn{reading} are the operations of converting Lisp
objects to textual form and vice versa. They use the printed objects to textual form and vice versa. They use the printed
representations and read syntax described in @ref{Types of Lisp Object}. representations and read syntax described in @ref{Lisp Data Types}.
This chapter describes the Lisp functions for reading and printing. This chapter describes the Lisp functions for reading and printing.
It also describes @dfn{streams}, which specify where to get the text (if It also describes @dfn{streams}, which specify where to get the text (if