## "Fossies" - the Fresh Open Source Software Archive

### Source code changes of the file "man/lispref/numbers.texi" betweenxemacs-21.4.22.tar.gz and xemacs-21.4.24.tar.bz2

About: XEmacs (an alternative to GNU Emacs) is a highly customizable open source text editor and application development system (current version).

numbers.texi  (xemacs-21.4.22):numbers.texi  (xemacs-21.4.24.tar.bz2)
skipping to change at line 35 skipping to change at line 35
* Predicates on Numbers:: Testing for numbers. * Predicates on Numbers:: Testing for numbers.
* Comparison of Numbers:: Equality and inequality predicates. * Comparison of Numbers:: Equality and inequality predicates.
* Numeric Conversions:: Converting float to integer and vice versa. * Numeric Conversions:: Converting float to integer and vice versa.
* Arithmetic Operations:: How to add, subtract, multiply and divide. * Arithmetic Operations:: How to add, subtract, multiply and divide.
* Rounding Operations:: Explicitly rounding floating point numbers. * Rounding Operations:: Explicitly rounding floating point numbers.
* Bitwise Operations:: Logical and, or, not, shifting. * Bitwise Operations:: Logical and, or, not, shifting.
* Math Functions:: Trig, exponential and logarithmic functions. * Math Functions:: Trig, exponential and logarithmic functions.
* Random Numbers:: Obtaining random integers, predictable or not. * Random Numbers:: Obtaining random integers, predictable or not.
@node Integer Basics @node Integer Basics, Float Basics, Numbers, Numbers
@section Integer Basics @section Integer Basics
The range of values for an integer depends on the machine. The The range of values for an integer depends on the machine. The
minimum range is @minus{}134217728 to 134217727 (28 bits; i.e., minimum range is @minus{}134217728 to 134217727 (28 bits; i.e.,
@ifinfo @ifinfo
-2**27 -2**27
@end ifinfo @end ifinfo
@tex @tex
\$-2^{27}\$ \$-2^{27}\$
@end tex @end tex
skipping to change at line 132 skipping to change at line 132
such functions may be either integers or markers, which is why we often such functions may be either integers or markers, which is why we often
give these arguments the name @var{int-or-marker}. When the argument give these arguments the name @var{int-or-marker}. When the argument
value is a marker, its position value is used and its buffer is ignored. value is a marker, its position value is used and its buffer is ignored.
@ignore @ignore
In version 19, except where @emph{integer} is specified as an In version 19, except where @emph{integer} is specified as an
argument, all of the functions for markers and integers also work for argument, all of the functions for markers and integers also work for
floating point numbers. floating point numbers.
@end ignore @end ignore
@node Float Basics @node Float Basics, Predicates on Numbers, Integer Basics, Numbers
@section Floating Point Basics @section Floating Point Basics
XEmacs supports floating point numbers. The precise range of floating XEmacs supports floating point numbers. The precise range of floating
point numbers is machine-specific; it is the same as the range of the C point numbers is machine-specific; it is the same as the range of the C
data type @code{double} on the machine in question. data type @code{double} on the machine in question.
The printed representation for floating point numbers requires either The printed representation for floating point numbers requires either
a decimal point (with at least one digit following), an exponent, or a decimal point (with at least one digit following), an exponent, or
both. For example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2}, both. For example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2},
@samp{1.5e3}, and @samp{.15e4} are five ways of writing a floating point @samp{1.5e3}, and @samp{.15e4} are five ways of writing a floating point
skipping to change at line 172 skipping to change at line 172
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):
@defun logb number @defun logb number
This function returns the binary exponent of @var{number}. More This function returns the binary exponent of @var{number}. More
precisely, the value is the logarithm of @var{number} base 2, rounded precisely, the value is the logarithm of @var{number} base 2, rounded
down to an integer. down to an integer.
@end defun @end defun
@node Predicates on Numbers @node Predicates on Numbers, Comparison of Numbers, Float Basics, Numbers
@section Type Predicates for Numbers @section Type Predicates for Numbers
The functions in this section test whether the argument is a number or The functions in this section test whether the argument is a number or
whether it is a certain sort of number. The functions @code{integerp} whether it is a certain sort of number. The functions @code{integerp}
and @code{floatp} can take any type of Lisp object as argument (the and @code{floatp} can take any type of Lisp object as argument (the
predicates would not be of much use otherwise); but the @code{zerop} predicates would not be of much use otherwise); but the @code{zerop}
predicate requires a number as its argument. See also predicate requires a number as its argument. See also
@code{integer-or-marker-p}, @code{integer-char-or-marker-p}, @code{integer-or-marker-p}, @code{integer-char-or-marker-p},
@code{number-or-marker-p} and @code{number-char-or-marker-p}, in @code{number-or-marker-p} and @code{number-char-or-marker-p}, in
@ref{Predicates on Markers}. @ref{Predicates on Markers}.
skipping to change at line 216 skipping to change at line 216
considered non-negative. considered non-negative.
@end defun @end defun
@defun zerop number @defun zerop number
This predicate tests whether its argument is zero, and returns @code{t} This predicate tests whether its argument is zero, and returns @code{t}
if so, @code{nil} otherwise. The argument must be a number. if so, @code{nil} otherwise. The argument must be a number.
These two forms are equivalent: @code{(zerop x)} @equiv{} @code{(= x 0)}. These two forms are equivalent: @code{(zerop x)} @equiv{} @code{(= x 0)}.
@end defun @end defun
@node Comparison of Numbers @node Comparison of Numbers, Numeric Conversions, Predicates on Numbers, Numbers
@section Comparison of Numbers @section Comparison of Numbers
@cindex number equality @cindex number equality
To test numbers for numerical equality, you should normally use To test numbers for numerical equality, you should normally use
@code{=}, not @code{eq}. There can be many distinct floating point @code{=}, not @code{eq}. There can be many distinct floating point
number objects with the same numeric value. If you use @code{eq} to number objects with the same numeric value. If you use @code{eq} to
compare them, then you test whether two values are the same compare them, then you test whether two values are the same
@emph{object}. By contrast, @code{=} compares only the numeric values @emph{object}. By contrast, @code{=} compares only the numeric values
of the objects. of the objects.
skipping to change at line 354 skipping to change at line 354
@defun min number &rest more-numbers @defun min number &rest more-numbers
This function returns the smallest of its arguments. This function returns the smallest of its arguments.
@example @example
(min -4 1) (min -4 1)
@result{} -4 @result{} -4
@end example @end example
@end defun @end defun
@node Numeric Conversions @node Numeric Conversions, Arithmetic Operations, Comparison of Numbers, Numbers
@section Numeric Conversions @section Numeric Conversions
@cindex rounding in conversions @cindex rounding in conversions
To convert an integer to floating point, use the function @code{float}. To convert an integer to floating point, use the function @code{float}.
@defun float number @defun float number
This returns @var{number} converted to floating point. This returns @var{number} converted to floating point.
If @var{number} is already a floating point number, @code{float} returns If @var{number} is already a floating point number, @code{float} returns
it unchanged. it unchanged.
@end defun @end defun
skipping to change at line 397 skipping to change at line 397
(towards positive infinity). (towards positive infinity).
@end defun @end defun
@defun round number @defun round number
This returns @var{number}, converted to an integer by rounding towards the This returns @var{number}, converted to an integer by rounding towards the
nearest integer. Rounding a value equidistant between two integers nearest integer. Rounding a value equidistant between two integers
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,
depending on your machine. depending on your machine.
@end defun @end defun
@node Arithmetic Operations @node Arithmetic Operations, Rounding Operations, Numeric Conversions, Numbers
@section Arithmetic Operations @section Arithmetic Operations
XEmacs Lisp provides the traditional four arithmetic operations: XEmacs Lisp provides the traditional four arithmetic operations:
addition, subtraction, multiplication, and division. Remainder and modulus addition, subtraction, multiplication, and division. Remainder and modulus
functions supplement the division functions. The functions to functions supplement the division functions. The functions to
add or subtract 1 are provided because they are traditional in Lisp and add or subtract 1 are provided because they are traditional in Lisp and
commonly used. commonly used.
All of these functions except @code{%} return a floating point value All of these functions except @code{%} return a floating point value
if any argument is floating. if any argument is floating.
skipping to change at line 639 skipping to change at line 639
(* (floor @var{dividend} @var{divisor}) @var{divisor})) (* (floor @var{dividend} @var{divisor}) @var{divisor}))
@end group @end group
@end example @end example
@noindent @noindent
always equals @var{dividend}, subject to rounding error if either always equals @var{dividend}, subject to rounding error if either
argument is floating point. For @code{floor}, see @ref{Numeric argument is floating point. For @code{floor}, see @ref{Numeric
Conversions}. Conversions}.
@end defun @end defun
@node Rounding Operations @node Rounding Operations, Bitwise Operations, Arithmetic Operations, Numbers
@section Rounding Operations @section Rounding Operations
@cindex rounding without conversion @cindex rounding without conversion
The functions @code{ffloor}, @code{fceiling}, @code{fround} and The functions @code{ffloor}, @code{fceiling}, @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{fceiling}, the nearest integer above; nearest integer below; @code{fceiling}, the nearest integer above;
@code{ftruncate}, 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.
skipping to change at line 670 skipping to change at line 670
@defun ftruncate number @defun ftruncate number
This function rounds @var{number} towards zero to an integral value, and This function rounds @var{number} 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
@defun fround number @defun fround number
This function rounds @var{number} to the nearest integral value, This function rounds @var{number} to the nearest integral value,
and returns that value as a floating point number. and returns that value as a floating point number.
@end defun @end defun
@node Bitwise Operations @node Bitwise Operations, Math Functions, Rounding Operations, Numbers
@section Bitwise Operations on Integers @section Bitwise Operations on Integers
In a computer, an integer is represented as a binary number, a In a computer, an integer is represented as a binary number, a
sequence of @dfn{bits} (digits which are either zero or one). A bitwise sequence of @dfn{bits} (digits which are either zero or one). A bitwise
operation acts on the individual bits of such a sequence. For example, operation acts on the individual bits of such a sequence. For example,
@dfn{shifting} moves the whole sequence left or right one or more places, @dfn{shifting} moves the whole sequence left or right one or more places,
reproducing the same pattern ``moved over''. reproducing the same pattern ``moved over''.
The bitwise operations in XEmacs Lisp apply only to integers. The bitwise operations in XEmacs Lisp apply only to integers.
skipping to change at line 975 skipping to change at line 975
@example @example
(lognot 5) (lognot 5)
@result{} -6 @result{} -6
;; 5 = @r{0000 0000 0000 0000 0000 0000 0101} ;; 5 = @r{0000 0000 0000 0000 0000 0000 0101}
;; @r{becomes} ;; @r{becomes}
;; -6 = @r{1111 1111 1111 1111 1111 1111 1010} ;; -6 = @r{1111 1111 1111 1111 1111 1111 1010}
@end example @end example
@end defun @end defun
@node Math Functions @node Math Functions, Random Numbers, Bitwise Operations, Numbers
@section Standard Mathematical Functions @section Standard Mathematical Functions
@cindex transcendental functions @cindex transcendental functions
@cindex mathematical functions @cindex mathematical functions
These mathematical functions are available if floating point is These mathematical functions are available if floating point is
supported (which is the normal state of affairs). They allow integers supported (which is the normal state of affairs). They allow integers
as well as floating point numbers as arguments. as well as floating point numbers as arguments.
@defun sin number @defun sin number
@defunx cos number @defunx cos number
skipping to change at line 1057 skipping to change at line 1057
@defun sqrt number @defun sqrt number
This returns the square root of @var{number}. If @var{number} is negative, This returns the square root of @var{number}. If @var{number} is negative,
the value is a NaN. the value is a NaN.
@end defun @end defun
@defun cube-root number @defun cube-root number
This returns the cube root of @var{number}. This returns the cube root of @var{number}.
@end defun @end defun
@node Random Numbers @node Random Numbers, , Math Functions, Numbers
@section Random Numbers @section Random Numbers
@cindex random numbers @cindex random numbers
A deterministic computer program cannot generate true random numbers. A deterministic computer program cannot generate true random numbers.
For most purposes, @dfn{pseudo-random numbers} suffice. A series of For most purposes, @dfn{pseudo-random numbers} suffice. A series of
pseudo-random numbers is generated in a deterministic fashion. The pseudo-random numbers is generated in a deterministic fashion. The
numbers are not truly random, but they have certain properties that numbers are not truly random, but they have certain properties that
mimic a random series. For example, all possible values occur equally mimic a random series. For example, all possible values occur equally
often in a pseudo-random series. often in a pseudo-random series.
End of changes. 10 change blocks.
10 lines changed or deleted 10 lines changed or added