mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
Handling zeros and infinities in 2-arg atan.
This commit is contained in:
parent
e701c63762
commit
cdc9465b1b
1 changed files with 11 additions and 5 deletions
|
@ -1114,14 +1114,20 @@
|
|||
(if (pair? o) (/ (ln x) (ln (car o))) (ln x)))
|
||||
|
||||
(define (atan y . o)
|
||||
(define (inf? z) (if (= +inf.0 z) #t (= -inf.0 z)))
|
||||
(if (null? o)
|
||||
(atan1 y)
|
||||
(let ((x (exact->inexact (car o))))
|
||||
(if (and (inf? x) (inf? y))
|
||||
(* (if (< y 0) -1 1) (if (= x -inf.0) 3 1) 0.7853981633974483)
|
||||
(if (negative? x)
|
||||
(if (negative? y)
|
||||
(- (atan1 (/ y x)) 3.141592653589793)
|
||||
(- 3.141592653589793 (atan1 (/ y (- x)))))
|
||||
(atan1 (/ y x))))))
|
||||
(if (and (zero? x) (zero? y))
|
||||
(* (if (eqv? y -0.0) -1 1)
|
||||
(if (eqv? x -0.0) 3.141592653589793 x))
|
||||
(atan1 (/ y x))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; string cursors
|
||||
|
|
Loading…
Add table
Reference in a new issue