| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section defines a few simple Common Lisp operations on numbers which were left out of Emacs Lisp.
| 9.1 Predicates on Numbers | `plusp', `oddp', `floatp-safe', etc. | |
| 9.2 Numerical Functions | `abs', `expt', `floor*', etc. | |
| 9.3 Random Numbers | `random*', `make-random-state' | |
| 9.4 Implementation Parameters | `most-positive-fixnum', `most-positive-float' |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions return t if the specified condition is
true of the numerical argument, or nil otherwise.
floatp. On other systems, this always returns nil.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions perform various arithmetic operations on numbers.
abs only for Emacs 18 versions which don't provide
it as a primitive.)
expt only for Emacs 18 versions which don't
provide it as a primitive.)
floor.
truncate.
The following functions are identical to their built-in counterparts,
without the trailing * in their names, but they return lists
instead of multiple values. @xref{(lispref.info)Rounding Operations}
All the above definitions are compatible with those in the Quiroz `cl.el' package, except that this package appends `*' to certain function names to avoid conflicts with existing Emacs 19 functions, and that the mechanism for returning multiple values is different.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This package also provides an implementation of the Common Lisp random number generator. It uses its own additive-congruential algorithm, which is much more likely to give statistically clean random numbers than the simple generators supplied by many operating systems.
random-state object
which holds the state of the random number generator. The
function modifies this state object as a side effect. If
state is omitted, it defaults to the variable
*random-state*, which contains a pre-initialized
random-state object.
random-state
object, used for calls to random* that do not specify an
alternative state object. Since any number of programs in the
Emacs process may be accessing *random-state* in interleaved
fashion, the sequence generated from this variable will be
irreproducible for all intents and purposes.
random-state object.
If state is omitted or nil, it returns a new copy of
*random-state*. This is a copy in the sense that future
sequences of calls to (random* n) and
(random* n s) (where s is the new
random-state object) will return identical sequences of random
numbers.
If state is a random-state object, this function
returns a copy of that object. If state is t, this
function returns a new random-state object seeded from the
date and time. As an extension to Common Lisp, state may also
be an integer in which case the new object is seeded from that
integer; each different integer seed will result in a completely
different sequence of random numbers.
It is legal to print a random-state object to a buffer or
file and later read it back with read. If a program wishes
to use a sequence of pseudo-random numbers which can be reproduced
later for debugging, it can call (make-random-state t) to
get a new sequence, then print this sequence to a file. When the
program is later rerun, it can read the original run's random-state
from the file.
t if object is a
random-state object, or nil otherwise.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This package defines several useful constants having to with numbers.
2^23-1 or 2^25-1.
The following parameters have to do with floating-point numbers. This package determines their values by exercising the computer's floating-point arithmetic in various ways. Because this operation might be slow, the code for initializing them is kept in a separate function that must be called before the parameters can be used.
most-positive-float have been initialized.
Until it is called, these parameters will be nil. If this
version of Emacs does not support floats (e.g., most versions of
Emacs 18), the parameters will remain nil. If the parameters
have already been initialized, the function returns immediately.
The algorithm makes assumptions that will be valid for most modern machines, but will fail if the machine's arithmetic is extremely unusual, e.g., decimal.
Since true Common Lisp supports up to four different floating-point
precisions, it has families of constants like
most-positive-single-float, most-positive-double-float,
most-positive-long-float, and so on. Emacs has only one
floating-point precision, so this package omits the precision word
from the constants' names.
1.79e+308.
(- most-positive-float).)
4.94e-324 if denormals are
supported or 2.22e-308 if not.
2.22e-308. For machines that do not support
the concept of denormalization and gradual underflow, this constant
will always equal least-positive-float.
least-positive-float.
least-positive-normalized-float.
2.22e-16.
1.11e-16.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |