Skip to content
Snippets Groups Projects
Commit 54caaf43 authored by rtoy's avatar rtoy
Browse files

CLHS 2.3.1.1 says if " token with the syntax of a number cannot be

converted to an internal number, an error of type reader-error is
signaled."

So, disable underflow traps, convert the number.  If the resulting
float is zero, but the number was not, signal a reader-error.
parent f4dfbd60
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.56 2005/05/06 20:36:31 rtoy Exp $")
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.57 2005/10/21 13:11:59 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
......@@ -1538,8 +1538,17 @@ the end of the stream."
(t (error "Internal error in floating point reader.")))))
(defun make-float-aux (number divisor float-format stream)
(handler-case
(coerce (/ number divisor) float-format)
(handler-case
(with-float-traps-masked (:underflow)
(let ((result (coerce (/ number divisor) float-format)))
(when (and (zerop result) (not (zerop number)))
;; With underflow traps disabled, reading any number
;; smaller than least-positive-foo-float will return zero.
;; But we really want to indicate that we can't read it.
;; So if we converted the number to zero, but the number
;; wasn't actually zero, throw an error.
(error "Underflow"))
result))
(error ()
(%reader-error stream "Floating-point number not representable"))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment