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
8167b21f
Commit
8167b21f
authored
34 years ago
by
ram
Browse files
Options
Downloads
Patches
Plain Diff
Fixed decode/scale float stuff to handle zero correctly.
parent
b8857614
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/numbers.lisp
+45
-33
45 additions, 33 deletions
code/numbers.lisp
with
45 additions
and
33 deletions
code/numbers.lisp
+
45
−
33
View file @
8167b21f
...
...
@@ -7,7 +7,7 @@
;;; Scott Fahlman (FAHLMAN@CMUC).
;;; **********************************************************************
;;;
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.
7
1990/07/0
8
1
1:48:19 wlott
Exp $
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.
8
1990/07/0
9
1
4:13:42 ram
Exp $
;;;
;;; This file contains the definitions of most number functions.
;;;
...
...
@@ -1312,8 +1312,10 @@
(
defun
integer-decode-single-float
(
x
)
(
declare
(
single-float
x
))
(
let
((
bits
(
single-float-bits
(
abs
x
))))
(
values
(
logior
(
ldb
single-float-significand-byte
bits
)
single-float-hidden-bit
)
(
values
(
if
(
zerop
x
)
0
(
logior
(
ldb
single-float-significand-byte
bits
)
single-float-hidden-bit
))
(
truly-the
single-float-exponent
(
-
(
ldb
single-float-exponent-byte
bits
)
single-float-bias
...
...
@@ -1325,10 +1327,12 @@
(
let*
((
abs
(
abs
x
))
(
hi
(
double-float-high-bits
abs
))
(
lo
(
double-float-low-bits
abs
)))
(
values
(
logior
(
ash
(
logior
(
ldb
double-float-significand-byte
hi
)
double-float-hidden-bit
)
32
)
lo
)
(
values
(
if
(
zerop
x
)
0
(
logior
(
ash
(
logior
(
ldb
double-float-significand-byte
hi
)
double-float-hidden-bit
)
32
)
lo
))
(
truly-the
double-float-exponent
(
-
(
ldb
double-float-exponent-byte
hi
)
double-float-bias
...
...
@@ -1354,8 +1358,10 @@
(
defun
decode-single-float
(
x
)
(
declare
(
single-float
x
))
(
let
((
bits
(
single-float-bits
(
abs
x
))))
(
values
(
make-single-float
(
dpb
single-float-bias
single-float-exponent-byte
bits
))
(
values
(
if
(
zerop
x
)
0f0
(
make-single-float
(
dpb
single-float-bias
single-float-exponent-byte
bits
)))
(
truly-the
single-float-exponent
(
-
(
ldb
single-float-exponent-byte
bits
)
single-float-bias
))
...
...
@@ -1366,9 +1372,11 @@
(
let*
((
abs
(
abs
x
))
(
hi
(
double-float-high-bits
abs
))
(
lo
(
double-float-low-bits
abs
)))
(
values
(
make-double-float
(
dpb
double-float-bias
double-float-exponent-byte
hi
)
lo
)
(
values
(
if
(
zerop
x
)
0d0
(
make-double-float
(
dpb
double-float-bias
double-float-exponent-byte
hi
)
lo
))
(
truly-the
double-float-exponent
(
-
(
ldb
double-float-exponent-byte
hi
)
double-float-bias
))
...
...
@@ -1392,30 +1400,34 @@
(
defun
scale-single-float
(
x
exp
)
(
declare
(
single-float
x
)
(
fixnum
exp
))
(
let*
((
bits
(
single-float-bits
x
))
(
new-exp
(
+
(
ldb
single-float-exponent-byte
bits
)
exp
)))
(
unless
(
<=
single-float-normal-exponent-min
new-exp
single-float-normal-exponent-max
)
(
error
"Floating point over/underflow scaling ~S by ~S."
x
exp
))
(
make-single-float
(
dpb
new-exp
single-float-exponent-byte
bits
))))
(
if
(
zerop
x
)
x
(
let*
((
bits
(
single-float-bits
x
))
(
new-exp
(
+
(
ldb
single-float-exponent-byte
bits
)
exp
)))
(
unless
(
<=
single-float-normal-exponent-min
new-exp
single-float-normal-exponent-max
)
(
error
"Floating point over/underflow scaling ~S by ~S."
x
exp
))
(
make-single-float
(
dpb
new-exp
single-float-exponent-byte
bits
)))))
(
defun
scale-double-float
(
x
exp
)
(
declare
(
double-float
x
)
(
fixnum
exp
))
(
let
((
hi
(
double-float-high-bits
x
))
(
lo
(
double-float-low-bits
x
)))
(
let
((
new-exp
(
+
(
ldb
double-float-exponent-byte
hi
)
exp
)))
(
unless
(
<=
double-float-normal-exponent-min
new-exp
double-float-normal-exponent-max
)
(
error
"Floating point over/underflow scaling ~S by ~S."
x
exp
))
(
make-double-float
(
dpb
new-exp
double-float-exponent-byte
hi
)
lo
))))
(
if
(
zerop
x
)
x
(
let
((
hi
(
double-float-high-bits
x
))
(
lo
(
double-float-low-bits
x
)))
(
let
((
new-exp
(
+
(
ldb
double-float-exponent-byte
hi
)
exp
)))
(
unless
(
<=
double-float-normal-exponent-min
new-exp
double-float-normal-exponent-max
)
(
error
"Floating point over/underflow scaling ~S by ~S."
x
exp
))
(
make-double-float
(
dpb
new-exp
double-float-exponent-byte
hi
)
lo
)))))
(
defun
scale-float
(
f
ex
)
"Returns the value (* f (expt (float b f) e))"
...
...
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