... |
... |
@@ -1867,7 +1867,7 @@ the end of the stream." |
1867
|
1867
|
(%reader-error stream _"Number not representable as a ~S: ~S"
|
1868
|
1868
|
float-format (read-buffer-to-string)))))))
|
1869
|
1869
|
|
1870
|
|
- ;; Otherwise the number might fit, so we carefully compute the result
|
|
1870
|
+ ;; Otherwise the number might fit, so we carefully compute the result.
|
1871
|
1871
|
(handler-case
|
1872
|
1872
|
(with-float-traps-masked (:underflow)
|
1873
|
1873
|
(let* ((ratio (/ (* (expt 10 exponent) number)
|
... |
... |
@@ -1875,24 +1875,10 @@ the end of the stream." |
1875
|
1875
|
(result (coerce ratio float-format)))
|
1876
|
1876
|
(when (and (zerop result) (not (zerop number)))
|
1877
|
1877
|
;; The number we've read is so small that it gets
|
1878
|
|
- ;; converted to 0.0, but is not actually zero. In this
|
1879
|
|
- ;; case, we want to round such small numbers to
|
1880
|
|
- ;; least-positive-foo-float. If it's still too small, we
|
1881
|
|
- ;; want to signal an error saying that we can't really
|
1882
|
|
- ;; convert it because the exponent is too small.
|
1883
|
|
- ;; See CLHS 2.3.1.1.
|
1884
|
|
- (let ((float-limit (ecase float-format
|
1885
|
|
- ((short-float single-float)
|
1886
|
|
- least-positive-single-float)
|
1887
|
|
- (double-float
|
1888
|
|
- least-positive-double-float)
|
1889
|
|
- #+double-double
|
1890
|
|
- (double-double-float
|
1891
|
|
- ext:least-positive-double-double-float))))
|
1892
|
|
- (if (>= (* 2 ratio) float-limit)
|
1893
|
|
- (setf result float-limit)
|
1894
|
|
- (error _"Underflow"))))
|
1895
|
|
- result))
|
|
1878
|
+ ;; converted to 0.0, but is not actually zero. Signal an
|
|
1879
|
+ ;; error. See CLHS 2.3.1.1.
|
|
1880
|
+ (error _"Underflow"))
|
|
1881
|
+ result))
|
1896
|
1882
|
(error ()
|
1897
|
1883
|
(%reader-error stream _"Number not representable as a ~S: ~S"
|
1898
|
1884
|
float-format (read-buffer-to-string)))))
|