From: Taylor R Campbell Date: Sat, 1 Dec 2018 02:09:21 +0000 (+0000) Subject: Use real:abs, real:copysign. X-Git-Tag: mit-scheme-pucked-10.1.7~3^2~78 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=96eabe440c9870d1eb476cecd042e9abeac88898;p=mit-scheme.git Use real:abs, real:copysign. These aren't guaranteed to be flonums here. Mixed-exactness complex numbers are pretty silly. --- diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index 76aa51f88..160e6b7f6 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -2022,16 +2022,16 @@ USA. ;; Rotate from pi/2 to pi/4, or from -pi/2 to -pi/4, ;; or preserve NaN but keep real sign positive. (assert (or (real:infinite? y) (real:nan? y))) - (complex:%make-rectangular (flo:abs y) y)) + (complex:%make-rectangular (real:abs y) y)) ((and (real:infinite? x) (real:finite? y)) (if (real:negative? x) - (complex:%make-rectangular 0. (flo:copysign x y)) - (complex:%make-rectangular x (flo:copysign 0. y)))) + (complex:%make-rectangular 0. (real:copysign x y)) + (complex:%make-rectangular x (real:copysign 0. y)))) (else ;; Garbage in, garbage out. Try to preserve as much ;; NaNity as possible. (assert (or (real:nan? x) (real:nan? y))) - (complex:%make-rectangular (flo:abs x) y))))) + (complex:%make-rectangular (real:abs x) y))))) ((real:safe-negative? z) (complex:%make-rectangular 0 (x>=0 (real:negate z)))) (else diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index 025c5d4b6..f8a5cb6c9 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -765,17 +765,17 @@ USA. (+inf.0+0.i +inf.0+0.i) (+inf.0+0i +inf.0+0i) (-inf.0+1.i 0.+inf.0i) - (-inf.0+1i 0.+inf.0i ,expect-error) + (-inf.0+1i 0.+inf.0i) (+inf.0+1.i +inf.0+0.i) - (+inf.0+1i +inf.0+0.i ,expect-error) + (+inf.0+1i +inf.0+0.i) (-inf.0-0.i 0.-inf.0i) (-inf.0-0i 0+inf.0i) ;no exact signed zero (+inf.0-0.i +inf.0-0.i) (+inf.0-0i +inf.0-0i) (-inf.0-1.i 0.-inf.0i) - (-inf.0-1i 0.-inf.0i ,expect-error) + (-inf.0-1i 0.-inf.0i) (+inf.0-1.i +inf.0-0.i) - (+inf.0-1i +inf.0-0.i ,expect-error) + (+inf.0-1i +inf.0-0.i) (-inf.0i +inf.0-inf.0i) (+inf.0i +inf.0+inf.0i) (+0.-inf.0i +inf.0-inf.0i)