Commit 0674c0d2 authored by Daniel Kochmański's avatar Daniel Kochmański
Browse files

numbers: atan.ieee.1: we test signed 0 later

So we may simplify these tests and check for the exact sign of the
result.
parent c805bab9
...@@ -128,31 +128,23 @@ ...@@ -128,31 +128,23 @@
;;; ieee-fp tests ;;; ieee-fp tests
(deftest atan.ieee.1 :description "Verify if atan handles 0.0 correctly" (deftest atan.ieee.1 :description "Verify if atan handles 0.0 correctly"
(flet ((pip (a b) (flet ((+pi-p (elt) (< (abs (- pi elt)) 0.01))
;; we are not testing accuracy, so this simplified (+pi/2-p (elt) (< (abs (+ (/ pi 2) elt)) 0.01))
;; predicate would be sufficient for our needs. We are also (-pi/2-p (elt) (< (abs (- (/ pi 2) elt)) 0.01)))
;; not interested in sign of the result, because we don't ;; (atan +-0 +(anything-but-nan)) -> +-0
;; know whenever zero is signed or not. ;; (atan +-0 -(anything-but-nan)) -> +-pi
(<= (abs (- (abs a) (abs b))) 0.01))) ;; (atan +-(anything-but-0/nan) 0) -> +-pi/2
(every #'identity (every #'identity
(append (map 'list (lambda (n)
;; (atan +-0 +(anything-but-nan)) -> +-0 ;; notice, that we don't test a case, where
;; (atan +-0 -(anything-but-nan)) -> +-pi ;; both arguments are 0.0, because if
(map 'list (lambda (n) ;; implementation doesn't support signed 0
;; notice, that we don't test a case, where ;; result is undefined.
;; both arguments are 0.0, because if (and (zerop (atan 0.0 n))
;; implementation doesn't support signed 0 (+pi-p (atan 0.0 (- n)))
;; result is undefined. (+pi/2-p (atan n 0.0))
(and (zerop (atan -0.0 n)) (-pi/2-p (atan (- n) 0.0))))
(zerop (atan +0.0 n)) (remove-if-not #'plusp *floats*))))
(pip pi (atan +0.0 (- n)))
(pip pi (atan -0.0 (- n)))))
(remove-if-not #'plusp *floats*))
;; (atan +-(anything-but-0/nan) 0) -> +-pi/2
(map 'list (lambda (n)
(and (pip (* +1/2 pi) (atan n +0.0))
(pip (* -1/2 pi) (atan n -0.0))))
(remove-if #'zerop *floats*)))))
T) T)
(deftest atan.ieee.2 :description "Verify ATAN handling signed zero" (deftest atan.ieee.2 :description "Verify ATAN handling signed zero"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment