From: Taylor R Campbell Date: Sun, 18 Nov 2018 01:44:49 +0000 (+0000) Subject: Make (make-polar magnitude 0) return magnitude. X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~49 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=980cda77a35cfa557cb400633dd7053661ecc133;p=mit-scheme.git Make (make-polar magnitude 0) return magnitude. --- diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index 03b1cacac..77a53f280 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -1916,8 +1916,10 @@ USA. (make-recnum real imag))) (define (complex:%make-polar magnitude angle) - (complex:%make-rectangular (real:* magnitude (real:cos angle)) - (real:* magnitude (real:sin angle)))) + (if (real:exact0= angle) + magnitude + (complex:%make-rectangular (real:* magnitude (real:cos angle)) + (real:* magnitude (real:sin angle))))) (define (complex:real-part z) (cond ((recnum? z) (rec:real-part z)) diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index 7c533512a..5b3774f8d 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -138,15 +138,10 @@ USA. (assert-nan (apply * l)))) (define-enumerated-test 'polar0-real - (vector 0 0. -0. 1 1. -1.) + (vector 0 0. -0. 1 1. -1. (flo:+inf.0) (flo:-inf.0)) (lambda (magnitude) (assert-real (make-polar magnitude 0)))) -(define-enumerated-test 'polar0-real-xfail - (vector (flo:+inf.0) (flo:-inf.0)) - (lambda (magnitude) - (expect-failure (lambda () (assert-real (make-polar magnitude 0)))))) - (define-enumerated-test 'flo:ulp (vector (vector (flo:-inf.0) (flo:+inf.0))