Changeset 12897


Ignore:
Timestamp:
Sep 30, 2009, 3:22:23 AM (10 years ago)
Author:
rme
Message:

Add DOUBLE-FLOAT-NAN constant; use it in PARSE-FLOAT instead of computing
it (incorrectly) inline. Fixes ticket:502.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/numbers.lisp

    r10124 r12897  
    4747        (ccl:set-fpu-mode :division-by-zero division-by-zero))))
    4848
    49 
     49(defconstant double-float-nan
     50  #.(let ((invalid (get-fpu-mode :invalid)))
     51      (unwind-protect
     52           (progn
     53             (set-fpu-mode :invalid nil)
     54             (+ double-float-positive-infinity double-float-negative-infinity))
     55        (set-fpu-mode :invalid invalid))))
    5056
    5157(defun parse-float (str len off) 
     
    109115         (nan
    110116          (return-from parse-float
    111             (let* ((invalid (ccl:get-fpu-mode :invalid)))
    112             (unwind-protect
    113                 (progn
    114                   (ccl:set-fpu-mode :invalid nil)
    115                   (coerce
    116                    ;; we could also have used a double-float-nan
    117                    ;; variable binding here:
    118                    (+ double-float-positive-infinity
    119                       double-float-positive-infinity)
    120                    type))
    121               (ccl:set-fpu-mode :invalid invalid)))))
     117            (coerce double-float-nan type)))
    122118         (expt (setq expt (%i+ expt (* esign eexp))))
    123119         (t (return-from parse-float nil)))))
Note: See TracChangeset for help on using the changeset viewer.