From: Taylor R Campbell Date: Fri, 30 Nov 2018 07:26:07 +0000 (+0000) Subject: Tidy up some negative tests. No functional change intended. X-Git-Tag: mit-scheme-pucked-10.1.7~3^2~92 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=289ffe2e18d8bb3235a5ab86b6262f232515c81a;p=mit-scheme.git Tidy up some negative tests. No functional change intended. --- diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index 2ac8c786b..76aa51f88 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -1099,6 +1099,9 @@ USA. (define (real:positive? x) (if (flonum? x) (flo:positive? x) ((copy rat:positive?) x))) +(define (real:safe-negative? x) + (if (flonum? x) (flo:safe< x 0.) ((copy rat:negative?) x))) + (define-syntax define-standard-unary (sc-macro-transformer (lambda (form environment) @@ -1327,11 +1330,10 @@ USA. ((flonum? x) (flo:copysign x (real:->inexact y))) (else - (if (if (flonum? y) - (flo:sign-negative? y) - (rat:negative? y)) - (- (rat:abs x)) - (rat:abs x))))) + (let ((xa (rat:abs x))) + (if (real:sign-negative? y) + (rat:negate xa) + xa))))) (define (real:sign-negative? x) (if (flonum? x) @@ -1999,7 +2001,7 @@ USA. (y (rec:imag-part z))) (cond ((real:safe-zero? y) (assert (not (real:exact0= y))) - (if (if (flonum? x) (flo:safe< x 0.) (rat:negative? x)) + (if (real:safe-negative? x) (complex:%make-rectangular 0. (real:copysign (x>=0 (real:negate x)) y)) @@ -2030,7 +2032,7 @@ USA. ;; NaNity as possible. (assert (or (real:nan? x) (real:nan? y))) (complex:%make-rectangular (flo:abs x) y))))) - ((if (flonum? z) (flo:safe< z 0.) (rat:negative? z)) + ((real:safe-negative? z) (complex:%make-rectangular 0 (x>=0 (real:negate z)))) (else (x>=0 z))))