aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorPaul Eggert2019-11-10 15:01:06 -0800
committerPaul Eggert2019-11-10 15:04:20 -0800
commitb6942c0c37a504e00c717c8c74bfa9dcd208c931 (patch)
tree40565eb305e75021b6d96e90fd678c87a9de10be /doc/misc
parent6ad5eb97940b07bf8d28f8517608351b3af1221c (diff)
downloademacs-b6942c0c37a504e00c717c8c74bfa9dcd208c931.tar.gz
emacs-b6942c0c37a504e00c717c8c74bfa9dcd208c931.zip
Document Lisp floats a bit better
* doc/lispref/numbers.texi (Float Basics): * doc/misc/cl.texi (Implementation Parameters): * lisp/emacs-lisp/cl-lib.el (cl-most-positive-float) (cl-least-positive-float) (cl-least-positive-normalized-float, cl-float-epsilon) (cl-float-negative-epsilon): Document IEEE floating point better. Don’t suggest that Emacs might use some floating-point format other than IEEE format, as Emacs currently assumes IEEE in several places and there seems little point in removing those assumptions.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/cl.texi54
1 files changed, 24 insertions, 30 deletions
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 246f86bfd1a..cfdbc7c41b2 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -3113,48 +3113,42 @@ function that must be called before the parameters can be used.
3113@defun cl-float-limits 3113@defun cl-float-limits
3114This function makes sure that the Common Lisp floating-point parameters 3114This function makes sure that the Common Lisp floating-point parameters
3115like @code{cl-most-positive-float} have been initialized. Until it is 3115like @code{cl-most-positive-float} have been initialized. Until it is
3116called, these parameters will be @code{nil}. 3116called, these parameters have unspecified values.
3117@c If this version of Emacs does not support floats, the parameters will
3118@c remain @code{nil}.
3119If the parameters have already been initialized, the function returns 3117If the parameters have already been initialized, the function returns
3120immediately. 3118immediately.
3121
3122The algorithm makes assumptions that will be valid for almost all
3123machines, but will fail if the machine's arithmetic is extremely
3124unusual, e.g., decimal.
3125@end defun 3119@end defun
3126 3120
3127Since true Common Lisp supports up to four different kinds of floating-point 3121Since true Common Lisp supports up to four different kinds of floating-point
3128numbers, it has families of constants like 3122numbers, it has families of constants like
3129@code{most-positive-single-float}, @code{most-positive-double-float}, 3123@code{most-positive-single-float}, @code{most-positive-double-float},
3130@code{most-positive-long-float}, and so on. Emacs has only one 3124@code{most-positive-long-float}, and so on. This package uses just
3131kind of floating-point number, so this package just uses single constants. 3125one set of constants because Emacs has only one kind of
3126floating-point number, namely the IEEE binary64 floating-point format.
3127@xref{Float Basics,,,elisp,GNU Emacs Lisp Reference Manual}.
3132 3128
3133@defvar cl-most-positive-float 3129@defvar cl-most-positive-float
3134This constant equals the largest value a Lisp float can hold. 3130This constant equals the largest finite value a Lisp float can hold.
3135For those systems whose arithmetic supports infinities, this is 3131For IEEE binary64 format, this equals @code{(- (expt 2 1024) (- 2
3136the largest @emph{finite} value. For IEEE machines, the value 3132971))}, which equals @code{1.7976931348623157e+308}.
3137is approximately @code{1.79e+308}.
3138@end defvar 3133@end defvar
3139 3134
3140@defvar cl-most-negative-float 3135@defvar cl-most-negative-float
3141This constant equals the most negative value a Lisp float can hold. 3136This constant equals the most negative finite value a Lisp float can hold.
3142(It is assumed to be equal to @code{(- cl-most-positive-float)}.) 3137For IEEE binary64 format, this equals @code{(- cl-most-positive-float)}.
3143@end defvar 3138@end defvar
3144 3139
3145@defvar cl-least-positive-float 3140@defvar cl-least-positive-normalized-float
3146This constant equals the smallest Lisp float value greater than zero. 3141This constant equals the smallest positive Lisp float that is
3147For IEEE machines, it is about @code{4.94e-324} if denormals are 3142@dfn{normalized}, i.e., that has full precision.
3148supported or @code{2.22e-308} if not. 3143For IEEE binary64 format, this equals @code{(expt 2 -1022)},
3144which equals @code{2.2250738585072014e-308}.
3149@end defvar 3145@end defvar
3150 3146
3151@defvar cl-least-positive-normalized-float 3147@defvar cl-least-positive-float
3152This constant equals the smallest @emph{normalized} Lisp float greater 3148This constant equals the smallest Lisp float value greater than zero.
3153than zero, i.e., the smallest value for which IEEE denormalization 3149For IEEE binary64 format, this equals @code{5e-324} (which equals
3154will not result in a loss of precision. For IEEE machines, this 3150@code{(expt 2 -1074)}) if subnormal numbers are supported, and
3155value is about @code{2.22e-308}. For machines that do not support 3151@code{cl-least-positive-normalized-float} otherwise.
3156the concept of denormalization and gradual underflow, this constant
3157will always equal @code{cl-least-positive-float}.
3158@end defvar 3152@end defvar
3159 3153
3160@defvar cl-least-negative-float 3154@defvar cl-least-negative-float
@@ -3169,14 +3163,14 @@ This constant is the negative counterpart of
3169@defvar cl-float-epsilon 3163@defvar cl-float-epsilon
3170This constant is the smallest positive Lisp float that can be added 3164This constant is the smallest positive Lisp float that can be added
3171to 1.0 to produce a distinct value. Adding a smaller number to 1.0 3165to 1.0 to produce a distinct value. Adding a smaller number to 1.0
3172will yield 1.0 again due to roundoff. For IEEE machines, epsilon 3166will yield 1.0 again due to roundoff. For IEEE binary64 format, this
3173is about @code{2.22e-16}. 3167equals @code{(expt 2 -52)}, which equals @code{2.220446049250313e-16}.
3174@end defvar 3168@end defvar
3175 3169
3176@defvar cl-float-negative-epsilon 3170@defvar cl-float-negative-epsilon
3177This is the smallest positive value that can be subtracted from 3171This is the smallest positive value that can be subtracted from
31781.0 to produce a distinct value. For IEEE machines, it is about 31721.0 to produce a distinct value. For IEEE binary64 format, this
3179@code{1.11e-16}. 3173equals @code{(expt 2 -53)}, which equals @code{1.1102230246251565e-16}.
3180@end defvar 3174@end defvar
3181 3175
3182@node Sequences 3176@node Sequences