Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ansi-test
ansi-test
Commits
a1747969
Commit
a1747969
authored
Aug 27, 2019
by
Marius Gerbershagen
Browse files
numbers: fix signum tests to use approximate equal comparison
parent
9f06631f
Changes
2
Hide whitespace changes
Inline
Side-by-side
auxiliary/ansi-aux.lsp
View file @
a1747969
...
...
@@ -1137,6 +1137,9 @@ the condition to go uncaught if it cannot be classified."
(defun approx= (x y &optional (eps (epsilon x)))
(<= (abs (/ (- x y) (max (abs x) 1))) eps))
(defun approx-eql (x y)
(and (approx= x y) (typep x (type-of y))))
(defun epsilon (number)
(etypecase number
(complex (* 2 (epsilon (realpart number)))) ;; crude
...
...
numbers/signum.lsp
View file @
a1747969
...
...
@@ -77,35 +77,35 @@
for c2 = (complex onem z)
for c3 = (complex z one)
for c4 = (complex z onem)
unless (eql c1 (signum c1))
unless (
approx-
eql c1 (signum c1))
collect (list c1 (signum c1))
unless (eql c2 (signum c2))
unless (
approx-
eql c2 (signum c2))
collect (list c2 (signum c2))
unless (eql c3 (signum c3))
unless (
approx-
eql c3 (signum c3))
collect (list c3 (signum c3))
unless (eql c4 (signum c4))
unless (
approx-
eql c4 (signum c4))
collect (list c4 (signum c4)))
nil)
(deftest signum.8
(let* ((c (complex 0 1))
(s (signum c)))
(or (eql
t
c s)
(eql
t
s #c(0.0 1.0))))
(or (
approx-
eql c s)
(
approx-
eql s #c(0.0 1.0))))
t)
(deftest signum.9
(let* ((c (complex 0 -1))
(s (signum c)))
(or (eql
t
c s)
(eql
t
s #c(0.0 -1.0))))
(or (
approx-
eql c s)
(
approx-
eql s #c(0.0 -1.0))))
t)
(deftest signum.10
(let* ((c (complex 3/5 4/5))
(s (signum c)))
(or (eql
t
c s)
(eql
t
s (complex (float 3/5) (float 4/5)))))
(or (
approx-
eql c s)
(
approx-
eql s (complex (float 3/5) (float 4/5)))))
t)
(deftest signum.11
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment