Skip to content
Snippets Groups Projects
Commit a8bf72dd authored by wlott's avatar wlott
Browse files

Now that +0.0 and -0.0 are no longer eql, fixed atan to deal with them

correctly.
parent 8f5cbe12
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/irrat.lisp,v 1.12 1993/05/08 04:49:36 wlott Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/irrat.lisp,v 1.13 1993/05/25 22:09:17 wlott Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -321,40 +321,26 @@ ...@@ -321,40 +321,26 @@
"Return the arc tangent of Y if X is omitted or Y/X if X is supplied." "Return the arc tangent of Y if X is omitted or Y/X if X is supplied."
(if xp (if xp
(flet ((atan2 (y x) (flet ((atan2 (y x)
(declare (type double-float y x)) (declare (type double-float y x)
(if (plusp (float-sign x)) (values double-float))
;; X is either +0.0 or > 0.0 (if (zerop x)
(if (zerop x) (if (zerop y)
;; X is +0.0. (if (plusp (float-sign x))
(if (plusp (float-sign y)) y
;; Y is either +0.0 or > 0.0 (float-sign y pi))
(if (zerop y) +0.0d0 (/ pi 2)) (float-sign y (/ pi 2)))
;; Y is either -0.0 or < 0.0 (%atan2 y x))))
(if (zerop y) -0.0d0 (/ pi 2))) (number-dispatch ((y number) (x number))
;; X is > 0.0 ((double-float
(if (plusp (float-sign y)) (foreach double-float single-float fixnum bignum ratio))
;; Y is either +0.0 or > 0.0 (atan2 y (coerce x 'double-float)))
(if (zerop y) +0.0d0 (%atan2 y x)) (((foreach single-float fixnum bignum ratio)
;; Y is either -0.0 or < 0.0 double-float)
(if (zerop y) -0.0d0 (%atan2 y x)))) (atan2 (coerce y 'double-float) x))
;; X is either -0.0 or < 0.0 (((foreach single-float fixnum bignum ratio)
(if (zerop x) (foreach single-float fixnum bignum ratio))
;; X is -0.0 (coerce (atan2 (coerce y 'double-float) (coerce x 'double-float))
(if (plusp (float-sign y)) 'single-float))))
;; Y is either +0.0 or > 0.0
(if (zerop y) pi (/ pi 2))
;; Y is either -0.0 or < 0.0
(if (zerop y) (- pi) (- (/ pi 2))))
;; X is < 0.0
(if (zerop y) pi (%atan2 y x))))))
(atan2 (number-dispatch ((y real))
(((foreach fixnum bignum ratio single-float))
(coerce y 'double-float))
((double-float) y))
(number-dispatch ((x real))
(((foreach fixnum bignum ratio single-float))
(coerce x 'double-float))
((double-float) x))))
(number-dispatch ((y number)) (number-dispatch ((y number))
(handle-reals %atan y) (handle-reals %atan y)
((complex) ((complex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment