From 980cda77a35cfa557cb400633dd7053661ecc133 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 18 Nov 2018 01:44:49 +0000 Subject: [PATCH] Make (make-polar magnitude 0) return magnitude. --- src/runtime/arith.scm | 6 ++++-- tests/runtime/test-arith.scm | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) 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)) -- 2.25.1