Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
636a699c
Commit
636a699c
authored
28 years ago
by
pw
Browse files
Options
Downloads
Patches
Plain Diff
Ray Toy's fix for reading very large/small FP numbers
parent
95caf520
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/reader.lisp
+39
-7
39 additions, 7 deletions
code/reader.lisp
with
39 additions
and
7 deletions
code/reader.lisp
+
39
−
7
View file @
636a699c
...
...
@@ -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.2
1
199
4/10/31 04:11:27 ram
Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.2
2
199
7/03/20 21:53:49 pw
Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -1193,9 +1193,9 @@
(
do*
((
ch
char
(
inch-read-buffer
))
(
dig
(
and
(
not
(
eofp
ch
))
(
digit-char-p
ch
))
(
and
(
not
(
eofp
ch
))
(
digit-char-p
ch
))))
((
not
dig
)
(
setq
exponent
(
if
negative-exponent
(
-
exponent
)
exponent
)))
(
setq
exponent
(
+
(
*
exponent
10
)
dig
)))
((
not
dig
)
(
setq
exponent
(
if
negative-exponent
(
-
exponent
)
exponent
)))
(
setq
exponent
(
+
(
*
exponent
10
)
dig
)))
;;generate and return the float, depending on float-char:
(
let*
((
float-format
(
case
(
char-upcase
float-char
)
(
#\E
*read-default-float-format*
)
...
...
@@ -1203,9 +1203,41 @@
(
#\F
'single-float
)
(
#\D
'double-float
)
(
#\L
'long-float
)))
(
num
(
make-float-aux
number
divisor
float-format
)))
(
setq
num
(
*
num
(
expt
10
exponent
)))
(
return-from
make-float
(
if
negative-fraction
(
-
num
)
num
))))
num
)
;; toy@rtp.ericsson.se: We need to watch out if the
;; exponent is too small or too large. We add enough to
;; EXPONENT to make it within range and scale NUMBER
;; appropriately. This should avoid any unnecessary
;; underflow or overflow problems.
(
multiple-value-bind
(
min-expo
max-expo
)
(
case
float-format
(
short-float
(
values
#.
(
log
least-positive-normalized-short-float
10s0
)
#.
(
log
most-positive-short-float
10s0
)))
(
single-float
(
values
#.
(
log
least-positive-normalized-single-float
10f0
)
#.
(
log
most-positive-single-float
10f0
)))
(
double-float
(
values
#.
(
log
least-positive-normalized-double-float
10d0
)
#.
(
log
most-positive-double-float
10d0
)))
(
long-float
(
values
#.
(
log
least-positive-normalized-long-float
10L0
)
#.
(
log
most-positive-long-float
10L0
))))
(
let
((
correction
(
cond
((
<=
exponent
min-expo
)
(
ceiling
(
-
min-expo
exponent
)))
((
>=
exponent
max-expo
)
(
floor
(
-
max-expo
exponent
)))
(
t
0
))))
(
incf
exponent
correction
)
(
setf
number
(
/
number
(
expt
10
correction
)))
(
setq
num
(
make-float-aux
number
divisor
float-format
))
(
setq
num
(
*
num
(
expt
10
exponent
)))
(
return-from
make-float
(
if
negative-fraction
(
-
num
)
num
))))))
;;should never happen:
(
t
(
error
"Internal error in floating point reader."
)))))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment