From 61b33de49004f2764d832f6e34a4295f28e9609e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= <daniel@turtleware.eu>
Date: Thu, 22 Dec 2016 22:15:34 +0100
Subject: [PATCH] number: atan: be more precise with judging pi

---
 numbers/atan.lsp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/numbers/atan.lsp b/numbers/atan.lsp
index 9945574d..6c345c1f 100644
--- a/numbers/atan.lsp
+++ b/numbers/atan.lsp
@@ -128,9 +128,9 @@
 
 ;;; ieee-fp tests
 (deftest atan.ieee.1 :description "Verify if atan handles 0.0 correctly"
-  (flet ((+pi-p (elt) (< (abs (- pi elt)) 0.01))
-         (+pi/2-p (elt) (< (abs (- (/ pi 2) elt)) 0.01))
-         (-pi/2-p (elt) (< (abs (+ (/ pi 2) elt)) 0.01)))
+  (flet ((+pi-p (elt)   (= (coerce pi (type-of elt)) elt))
+         (+pi/2-p (elt) (approx= (coerce (/ pi +2) (type-of elt)) elt))
+         (-pi/2-p (elt) (approx= (coerce (/ pi -2) (type-of elt)) elt)))
     ;; (atan +-0 +(anything-but-nan))  -> +-0
     ;; (atan +-0 -(anything-but-nan))  -> +-pi
     ;; (atan +-(anything-but-0/nan) 0) -> +-pi/2
@@ -155,8 +155,8 @@
              (-zerop (elt)
                (and (zerop elt)
                     (minusp (float-sign elt))))
-             (+pi-p (elt) (< (abs (- pi elt)) 0.01))
-             (-pi-p (elt) (< (abs (+ pi elt)) 0.01)))
+             (+pi-p (elt) (= (coerce pi (type-of elt)) elt))
+             (-pi-p (elt) (= (coerce pi (type-of elt)) (- elt))))
         (and
          (+zerop (atan +0.0 +0.0))
          (-zerop (atan -0.0 +0.0))
-- 
GitLab