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
445e115a
Commit
445e115a
authored
33 years ago
by
wlott
Browse files
Options
Downloads
Patches
Plain Diff
Added declarations, etc. to reduce number consing.
parent
3720ba58
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/bignum.lisp
+16
-12
16 additions, 12 deletions
code/bignum.lisp
with
16 additions
and
12 deletions
code/bignum.lisp
+
16
−
12
View file @
445e115a
...
...
@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/bignum.lisp,v 1.1
6
1991/0
2/08
1
3
:3
0:56 ram
Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/bignum.lisp,v 1.1
7
1991/0
5/24
1
9
:3
5:06 wlott
Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -406,7 +406,8 @@
(
multiple-value-bind
(
v
k
)
(
%add-with-carry
(
%bignum-ref
a
i
)
sign-digit-b
carry
)
(
setf
(
%bignum-ref
res
i
)
v
)
(
setf
carry
k
))))
(
setf
carry
k
)))
(
ext:undefined-value
))
;;;; Subtraction.
...
...
@@ -740,6 +741,8 @@
,
carry
))
(
i
1
)
(
,
end
,
bignum-len
))
(
declare
(
type
bit
,
carry
)
(
type
bignum-index
i
,
end
))
(
loop
(
when
(
=
i
,
end
)
(
return
))
(
multiple-value-bind
(
,
value
temp
)
...
...
@@ -949,7 +952,8 @@
;;;
(
defun
bignum-ashift-left-unaligned
(
bignum
digits
n-bits
res-len
&optional
(
res
nil
resp
))
(
declare
(
type
bignum-index
digits
res-len
))
(
declare
(
type
bignum-index
digits
res-len
)
(
type
(
mod
#.
digit-size
)
n-bits
))
(
let*
((
remaining-bits
(
-
digit-size
n-bits
))
(
res-len-1
(
1-
res-len
))
(
res
(
or
res
(
%allocate-bignum
res-len
))))
...
...
@@ -1031,6 +1035,7 @@
;;; result doesn't overflow.
;;;
(
defun
float-bignum-ratio
(
ratio
format
)
(
declare
(
optimize
(
ext:inhibit-warnings
3
)))
(
let*
((
bits-to-keep
(
+
(
float-format-digits
format
)
digit-size
))
(
num
(
numerator
ratio
))
(
num-len
(
integer-length
num
))
...
...
@@ -1052,6 +1057,7 @@
;;;
(
defun
single-float-from-bits
(
bits
exp
plusp
)
(
declare
(
fixnum
exp
))
(
declare
(
optimize
(
ext:inhibit-warnings
3
)))
(
let
((
res
(
dpb
exp
vm:single-float-exponent-byte
(
logandc2
(
ext:truly-the
(
unsigned-byte
31
)
...
...
@@ -1064,6 +1070,7 @@
;;;
(
defun
double-float-from-bits
(
bits
exp
plusp
)
(
declare
(
fixnum
exp
))
(
declare
(
optimize
(
ext:inhibit-warnings
3
)))
(
let
((
hi
(
dpb
exp
vm:double-float-exponent-byte
(
logandc2
(
ext:truly-the
(
unsigned-byte
31
)
...
...
@@ -1101,6 +1108,7 @@
(
1+
len
))
(
float-from-bits
rounded
len
))))
(
float-from-bits
(
bits
len
)
(
declare
(
type
bignum-index
len
))
(
ecase
format
(
single-float
(
single-float-from-bits
...
...
@@ -1115,6 +1123,7 @@
vm:double-float-normal-exponent-max
)
plusp
))))
(
check-exponent
(
exp
bias
max
)
(
declare
(
type
bignum-index
len
))
(
let
((
exp
(
+
exp
bias
)))
(
when
(
>
exp
max
)
(
error
"Too large to be represented as a ~S:~% ~S"
...
...
@@ -2173,6 +2182,9 @@ IS LESS EFFICIENT BUT EASIER TO MAINTAIN. BILL SAYS THIS CODE CERTAINLY WORKS!
;;; tells us how many high zeros there are which is one more than the shift
;;; amount sought.
;;;
;;; Note: This is exactly the same as one less than the integer-length of the
;;; last digit subtracted from the digit-size.
;;;
;;; We shift y to make it sufficiently large that doing the 64-bit by 32-bit
;;; %FLOOR calls ensures the quotient and remainder fit in 32-bits.
;;;
...
...
@@ -2181,15 +2193,7 @@ IS LESS EFFICIENT BUT EASIER TO MAINTAIN. BILL SAYS THIS CODE CERTAINLY WORKS!
(
last
(
%bignum-ref
y
(
1-
len
))))
(
declare
(
type
bignum-index
len
)
(
type
bignum-element-type
last
))
(
if
(
zerop
last
)
(
1-
digit-size
)
(
-
digit-size
(
do
((
i
0
(
1+
i
)))
((
zerop
last
)
;; I is guaranteed to be less than digit-size.
i
)
(
setf
last
(
ash
last
-1
)))
1
))))
(
-
digit-size
(
integer-length
last
)
1
)))
;;; SHIFT-AND-STORE-TRUNCATE-BUFFERS -- Internal.
;;;
...
...
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