- (flo:safe-zero? x) is true if x is zero; false if subnormal, normal,
infinite, or NaN. flo:zero? raises an invalid-operation exception on
NaN; flo:safe-zero? never does even on signalling NaN.
-- (flo:safe-negative? x) returns true if x has negative sign, false if
+- (flo:sign-negative? x) returns true if x has negative sign, false if
x has positive sign. Note that (flo:negative? 0.) and (flo:negative?
- -0.) both return false, while (flo:safe-negative? -0.) returns true.
+ -0.) both return false, while (flo:sign-negative? -0.) returns true.
Also, flo:negative? raises invalid-operation exception on NaN, while
- flo:safe-negative? never does even on signalling NaN.
+ flo:sign-negative? never does even on signalling NaN.
- (flo:safe< x y), (flo:safe<= x y), (flo:safe> x y), (flo:safe>= x y),
(flo:safe= x y), (flo:safe<> x y), (flo:unordered? x y) perform
unordered floating-point comparisons and, unlike flo:< &c., do not
(flo:copysign x (real:->inexact y)))
(else
(if (if (flonum? y)
- (flo:safe-negative? y)
+ (flo:sign-negative? y)
(rat:negative? y))
(- (rat:abs x))
(rat:abs x)))))
-(define (real:safe-negative? x)
+(define (real:sign-negative? x)
(if (flonum? x)
- (flo:safe-negative? x)
+ (flo:sign-negative? x)
((copy rat:negative?) x)))
\f
(define-syntax define-transcendental-unary
"-inf.0"
(string-append "-" (x>0 x)))))
((flo:zero? x)
- (if (flo:safe-negative? x) "-0." "0."))
+ (if (flo:sign-negative? x) "-0." "0."))
(else
"+nan.0")))))
(flo:infinite? flonum-is-infinite? 1)
(flo:nan? flonum-is-nan? 1)
(flo:normal? flonum-is-normal? 1)
- (flo:safe-negative? flonum-is-negative? 1)
+ (flo:sign-negative? flonum-is-negative? 1)
(flo:safe-zero? flonum-is-zero? 1)
(flo:= flonum-equal? 2)
(flo:< flonum-less? 2)
;; signalling NaN.
(cond ((not (flo:nan? y))
(assert (flo:nan? x))
- (if (flo:safe-negative? x) -1 +1))
+ (if (flo:sign-negative? x) -1 +1))
((not (flo:nan? x))
(assert (flo:nan? y))
- (if (flo:safe-negative? y) +1 -1))
+ (if (flo:sign-negative? y) +1 -1))
(else
(assert (flo:nan? x))
(assert (flo:nan? y))
- (let ((x- (flo:safe-negative? x))
+ (let ((x- (flo:sign-negative? x))
(xq (flo:nan-quiet? x))
(xp (flo:nan-payload x))
- (y- (flo:safe-negative? y))
+ (y- (flo:sign-negative? y))
(yq (flo:nan-quiet? y))
(yp (flo:nan-payload y)))
(cond ((not (eq? x- y-)) (if x- -1 +1))
(else
;; -0. < +0.
(assert (flo:zero? y))
- (if (flo:safe-negative? x)
- (if (flo:safe-negative? y) 0 -1)
- (if (flo:safe-negative? y) +1 0))))))
+ (if (flo:sign-negative? x)
+ (if (flo:sign-negative? y) 0 -1)
+ (if (flo:sign-negative? y) +1 0))))))
(define (flo:total-order-mag x y)
(flo:total-order (flo:abs x) (flo:abs y)))
;; signalling NaN.
(cond ((not (flo:nan? y))
(assert (flo:nan? x))
- (flo:safe-negative? x))
+ (flo:sign-negative? x))
((not (flo:nan? x))
(assert (flo:nan? y))
- (not (flo:safe-negative? y)))
+ (not (flo:sign-negative? y)))
(else
(assert (flo:nan? x))
(assert (flo:nan? y))
- (let ((x- (flo:safe-negative? x))
+ (let ((x- (flo:sign-negative? x))
(xq (flo:nan-quiet? x))
(xp (flo:nan-payload x))
- (y- (flo:safe-negative? y))
+ (y- (flo:sign-negative? y))
(yq (flo:nan-quiet? y))
(yp (flo:nan-payload y)))
(cond ((not (eq? x- y-)) (and x- (not y-)))
(else
;; -0. < +0.
(assert (flo:zero? y))
- (and (flo:safe-negative? x)
- (not (flo:safe-negative? y)))))))
+ (and (flo:sign-negative? x)
+ (not (flo:sign-negative? y)))))))
(define (flo:total-mag< x y)
(flo:total< (flo:abs x) (flo:abs y)))
(not (flo:nan? y))
(flo:= x y)
(or (not (flo:zero? x))
- (eq? (flo:safe-negative? x)
- (flo:safe-negative? y)))))
+ (eq? (flo:sign-negative? x)
+ (flo:sign-negative? y)))))
\f
;;; Measure the distance from x to the next floating-point number of
;;; the same sign as x and larger in magnitude. For +/-0, this yields
flo:qnan?
flo:round
flo:round->exact
- flo:safe-negative?
flo:safe-zero?
flo:safe<
flo:safe<=
flo:safe=
flo:safe>
flo:safe>=
+ flo:sign-negative?
flo:sin
flo:sinh
flo:snan
(flo:positive? flonum-positive?)
(flo:round flonum-round)
(flo:round->exact flonum-round->exact)
- (flo:safe-negative? flonum-is-negative?)
(flo:safe< flonum-is-less?)
(flo:safe<= flonum-is-less-or-equal?)
(flo:safe<> flonum-is-less-or-greater?)
(flo:safe> flonum-is-greater?)
(flo:safe>= flonum-is-greater-or-equal?)
+ (flo:sign-negative? flonum-is-negative?)
(flo:sin flonum-sin)
(flo:sqrt flonum-sqrt)
(flo:tan flonum-tan)
(if (and (flo:flonum? x) (flo:nan? x))
(and (flo:flonum? y)
(flo:nan? y)
- (eqv? (flo:safe-negative? x) (flo:safe-negative? y))
+ (eqv? (flo:sign-negative? x) (flo:sign-negative? y))
(eqv? (flo:nan-quiet? x) (flo:nan-quiet? y))
(eqv? (flo:nan-payload x) (flo:nan-payload y)))
(and (not (and (flo:flonum? y) (flo:nan? y)))
(define (eqv-nan? x y)
(if (flo:nan? x)
(and (flo:nan? y)
- (eqv? (flo:safe-negative? x) (flo:safe-negative? y))
+ (eqv? (flo:sign-negative? x) (flo:sign-negative? y))
(eqv? (flo:nan-quiet? x) (flo:nan-quiet? y))
(eqv? (flo:nan-payload x) (flo:nan-payload y)))
(and (not (flo:nan? y))
(lambda (x v)
(assert-eqv (yes-traps (lambda () (flo:nan? x))) v)))
-(define-enumerated-test 'safe-negative? ;XXX Maybe call it signbit?
+(define-enumerated-test 'sign-negative?
`((-inf.0 #t)
(-1. #t)
(,subnormal- #t)
;; (+nan.0 ...) ; indeterminate
)
(lambda (x n?)
- (assert-eqv (yes-traps (lambda () (flo:safe-negative? x))) n?)))
+ (assert-eqv (yes-traps (lambda () (flo:sign-negative? x))) n?)))
(define-syntax define-comparison-test
(syntax-rules ()
(if quiet?
(assert-qnan nan)
(assert-snan nan))
- (assert-eqv (flo:safe-negative? nan) negative?)
+ (assert-eqv (flo:sign-negative? nan) negative?)
(assert-eqv (flo:nan-quiet? nan) quiet?)
(assert-eqv (flo:nan-payload nan) payload))))
(with-expected-failure xfail
(lambda ()
(let ((y (yes-traps (lambda () (flo:abs x)))))
- (assert-false (flo:safe-negative? y))
+ (assert-false (flo:sign-negative? y))
(assert-eqv (flo:classify y) (flo:classify x))
(if (flo:nan? x)
(begin
(let ((y (yes-traps (lambda () (flo:negate x)))))
(assert-eqv-nan y z)
(assert-eqv-nan (flo:abs x) (flo:abs y))
- (assert-eqv (flo:safe-negative? y)
- (not (flo:safe-negative? x)))
+ (assert-eqv (flo:sign-negative? y)
+ (not (flo:sign-negative? x)))
(assert-eqv (flo:classify y) (flo:classify x))
(if (flo:nan? x)
(begin