From: Chris Hanson Date: Fri, 29 Dec 1989 19:19:12 +0000 (+0000) Subject: Fix definitions of `complex:acos' and `complex:angle' to handle X-Git-Tag: 20090517-FFI~11608 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=2919e3018f0a2bc45ee1996c447905a7fb84951c;p=mit-scheme.git Fix definitions of `complex:acos' and `complex:angle' to handle boundary conditions. --- diff --git a/v7/src/runtime/arith.scm b/v7/src/runtime/arith.scm index 572759db6..d6ddb3784 100644 --- a/v7/src/runtime/arith.scm +++ b/v7/src/runtime/arith.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/arith.scm,v 1.10 1989/11/30 07:52:42 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/arith.scm,v 1.11 1989/12/29 19:19:12 cph Exp $ Copyright (c) 1989 Massachusetts Institute of Technology @@ -1390,7 +1390,9 @@ MIT in each case. |# ((copy real:asin) z)))))) (define (complex:acos z) - (if (recnum? z) + (if (or (recnum? z) + (real:< z -1) + (real:< 1 z)) (complex:- rec:pi/2 (complex:asin z)) ((copy real:acos) z))) @@ -1492,12 +1494,13 @@ MIT in each case. |# (real:abs z))) (define (complex:angle z) - (if (recnum? z) - (if (and (real:zero? (rec:real-part z)) - (real:zero? (rec:imag-part z))) - (real:0 (complex:exact? z)) - (real:atan2 (rec:imag-part z) (rec:real-part z))) - (real:0 (real:exact? z)))) + (cond ((recnum? z) + (if (and (real:zero? (rec:real-part z)) + (real:zero? (rec:imag-part z))) + (real:0 (complex:exact? z)) + (real:atan2 (rec:imag-part z) (rec:real-part z)))) + ((real:negative? z) rec:pi) + (else (real:0 (real:exact? z))))) (define (complex:exact->inexact z) (if (recnum? z)