comparison lisp/cl.el @ 5385:436e67ca8c79

Give docstrings to least-{positive,negative}-normalized-float, float-*epsilon 2011-03-29 Aidan Kehoe <kehoea@parhasard.net> * cl.el: * cl.el (least-positive-float): * cl.el (least-positive-normalized-float): * cl.el (least-negative-normalized-float): * cl.el (float-epsilon): * cl.el (float-negative-epsilon): Document some previously-undocumented float constants here. * cl.el (oddp): * cl.el (evenp): Change numeric comparison to use #'eql instead of #'eq in passing.
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 29 Mar 2011 17:28:34 +0100
parents 22c4e67a2e69
children 25c10648ffba
comparison
equal deleted inserted replaced
5384:3889ef128488 5385:436e67ca8c79
310 "Return t if NUMBER is negative." 310 "Return t if NUMBER is negative."
311 (< number 0)) 311 (< number 0))
312 312
313 (defun oddp (integer) 313 (defun oddp (integer)
314 "Return t if INTEGER is odd." 314 "Return t if INTEGER is odd."
315 (eq (logand integer 1) 1)) 315 (eql (logand integer 1) 1))
316 316
317 (defun evenp (integer) 317 (defun evenp (integer)
318 "Return t if INTEGER is even." 318 "Return t if INTEGER is even."
319 (eq (logand integer 1) 0)) 319 (eql (logand integer 1) 0))
320 320
321 ;; XEmacs addition 321 ;; XEmacs addition
322 (defalias 'cl-abs 'abs) 322 (defalias 'cl-abs 'abs)
323 323
324 (defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time))) 324 (defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time)))
327 (defconst most-positive-float nil 327 (defconst most-positive-float nil
328 "The float closest in value to positive infinity.") 328 "The float closest in value to positive infinity.")
329 (defconst most-negative-float nil 329 (defconst most-negative-float nil
330 "The float closest in value to negative infinity.") 330 "The float closest in value to negative infinity.")
331 (defconst least-positive-float nil 331 (defconst least-positive-float nil
332 "The positive float closest in value to 0.") 332 "The positive float closest in value to zero.")
333 (defconst least-negative-float nil 333 (defconst least-negative-float nil
334 "The negative float closest in value to 0.") 334 "The negative float closest in value to zero.")
335 (defconst least-positive-normalized-float nil) 335 (defconst least-positive-normalized-float nil
336 (defconst least-negative-normalized-float nil) 336 "The normalized positive float closest in value to zero.
337 (defconst float-epsilon nil) 337
338 (defconst float-negative-epsilon nil) 338 A float is normalized if the most significant bit of its mantissa is 1.
339 Use of denormalized (equivalently, subnormal) floats in calculations will
340 lead to gradual underflow, though they can be more accurate in representing
341 individual small values. Normal and subnormal floats are as described in
342 IEEE 754.")
343
344 (defconst least-negative-normalized-float nil
345 "The normalized negative float closest in value to zero.
346
347 See `least-positive-normalized-float' for details of normal and denormalized
348 numbers.")
349
350 (defconst float-epsilon nil
351 "The smallest float guaranteed not `eql' to 1.0 when added to 1.0.
352
353 That is, (eql 1.0 (+ 1.0 X)) will always give nil if (<= float-epsilon X) ,
354 but it may give t for smaller values.")
355
356 (defconst float-negative-epsilon nil
357 "The smallest float guaranteed not `eql' to 1.0 when subtracted from 1.0.
358
359 That is, (eql 1.0 (- 1.0 X)) will always give nil if (<=
360 float-negative-epsilon X) , but it may give t for smaller values.")
339 361
340 ;;; Sequence functions. 362 ;;; Sequence functions.
341 363
342 (defalias 'copy-seq 'copy-sequence) 364 (defalias 'copy-seq 'copy-sequence)
343 365