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
770d63f6
Commit
770d63f6
authored
34 years ago
by
ram
Browse files
Options
Downloads
Patches
Plain Diff
Initial revision
parent
50a63312
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/bignum-test.lisp
+88
-0
88 additions, 0 deletions
code/bignum-test.lisp
code/float.lisp
+772
-0
772 additions, 0 deletions
code/float.lisp
with
860 additions
and
0 deletions
code/bignum-test.lisp
0 → 100644
+
88
−
0
View file @
770d63f6
;;;; -*- Package: Bignum -*-
;;;;
;;;; Some stuff to check that bignum operations are retuning the correct
;;;; results.
;;;;
(
in-package
"BIGNUM"
)
(
defvar
*in-bignum-wrapper*
nil
)
(
defmacro
def-bignum-wrapper
(
name
args
&body
body
)
(
let
((
var-name
(
ext:symbolicate
"*OLD-"
name
"*"
))
(
wrap-name
(
ext:symbolicate
"WRAP-"
name
)))
`
(
progn
(
defvar
,
var-name
(
fdefinition
',name
))
(
defun
,
wrap-name
,
args
(
if
*in-bignum-wrapper*
(
funcall
,
var-name
,@
args
)
(
let
((
*in-bignum-wrapper*
t
))
,@
body
)))
(
setf
(
fdefinition
',name
)
#'
,
wrap-name
))))
(
defun
big=
(
x
y
)
(
=
(
if
(
typep
x
'bignum
)
(
%normalize-bignum
x
(
%bignum-length
x
))
x
)
(
if
(
typep
y
'bignum
)
(
%normalize-bignum
y
(
%bignum-length
y
))
y
)))
(
def-bignum-wrapper
add-bignums
(
x
y
)
(
let
((
res
(
funcall
*old-add-bignums*
x
y
)))
(
assert
(
big=
(
-
res
y
)
x
))
res
))
(
def-bignum-wrapper
multiply-bignums
(
x
y
)
(
let
((
res
(
funcall
*old-multiply-bignums*
x
y
)))
(
if
(
zerop
x
)
(
assert
(
zerop
res
))
(
multiple-value-bind
(
q
r
)
(
truncate
res
x
)
(
assert
(
and
(
zerop
r
)
(
big=
q
y
)))))
res
))
(
def-bignum-wrapper
negate-bignum
(
x
)
(
let
((
res
(
funcall
*old-negate-bignum*
x
)))
(
assert
(
big=
(
-
res
)
x
))
res
))
(
def-bignum-wrapper
subtract-bignum
(
x
y
)
(
let
((
res
(
funcall
*old-subtract-bignum*
x
y
)))
(
assert
(
big=
(
+
res
y
)
x
))
res
))
(
def-bignum-wrapper
multiply-bignum-and-fixnum
(
x
y
)
(
let
((
res
(
funcall
*old-multiply-bignum-and-fixnum*
x
y
)))
(
if
(
zerop
x
)
(
assert
(
zerop
res
))
(
multiple-value-bind
(
q
r
)
(
truncate
res
x
)
(
assert
(
and
(
zerop
r
)
(
big=
q
y
)))))
res
))
(
def-bignum-wrapper
multiply-fixnums
(
x
y
)
(
let
((
res
(
funcall
*old-multiply-fixnums*
x
y
)))
(
if
(
zerop
x
)
(
assert
(
zerop
res
))
(
multiple-value-bind
(
q
r
)
(
truncate
res
x
)
(
assert
(
and
(
zerop
r
)
(
big=
q
y
)))))
res
))
(
def-bignum-wrapper
bignum-ashift-right
(
x
shift
)
(
let
((
res
(
funcall
*old-bignum-ashift-right*
x
shift
)))
(
assert
(
big=
(
ash
res
shift
)
(
logand
x
(
ash
-1
shift
))))
res
))
(
def-bignum-wrapper
bignum-ashift-left
(
x
shift
)
(
let
((
res
(
funcall
*old-bignum-ashift-left*
x
shift
)))
(
assert
(
big=
(
ash
res
(
-
shift
))
x
))
res
))
(
def-bignum-wrapper
bignum-truncate
(
x
y
)
(
multiple-value-bind
(
q
r
)
(
funcall
*old-bignum-truncate*
x
y
)
(
assert
(
big=
(
+
(
*
q
y
)
r
)
x
))
(
values
q
r
)))
(
def-bignum-wrapper
bignum-compare
(
x
y
)
(
let
((
res
(
funcall
*old-bignum-compare*
x
y
)))
(
assert
(
big=
(
signum
(
-
x
y
))
res
))
res
))
This diff is collapsed.
Click to expand it.
code/float.lisp
0 → 100644
+
772
−
0
View file @
770d63f6
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