}
}
\f
-/* C99 flonum predicates */
+/* IEEE 754 quiet predicates */
DEFINE_PRIMITIVE ("FLONUM-IS-FINITE?", Prim_flonum_is_finite_p, 1, 1, 0)
{
PRIMITIVE_RETURN
(BOOLEAN_TO_OBJECT (isunordered ((arg_flonum (1)), (arg_flonum (2)))));
}
+
+DEFINE_PRIMITIVE ("FLONUM-IS-EQUAL?", Prim_flonum_is_equal_p, 2, 2, 0)
+{
+ PRIMITIVE_HEADER (2);
+ {
+ double x = (arg_flonum (1));
+ double y = (arg_flonum (2));
+ PRIMITIVE_RETURN
+ (BOOLEAN_TO_OBJECT ((islessequal (x, y)) && (isgreaterequal (x, y))));
+ }
+}
+
+DEFINE_PRIMITIVE ("FLONUM-IS-ZERO?", Prim_flonum_is_zero_p, 1, 1, 0)
+{
+ PRIMITIVE_HEADER (1);
+ {
+ double x = (arg_flonum (1));
+ PRIMITIVE_RETURN (BOOLEAN_TO_OBJECT ((fpclassify (x)) == FP_ZERO));
+ }
+}
\f
/* Miscellaneous floating-point operations */
(flo:nan? flonum-is-nan? 1)
(flo:normal? flonum-is-normal? 1)
(flo:safe-negative? flonum-is-negative? 1)
+ (flo:safe-zero? flonum-is-zero? 1)
(flo:= flonum-equal? 2)
(flo:< flonum-less? 2)
(flo:> flonum-greater? 2)
(flo:safe< flonum-is-less? 2)
(flo:safe<= flonum-is-less-or-equal? 2)
(flo:safe<> flonum-is-less-or-greater? 2)
+ (flo:safe= flonum-is-equal? 2)
(flo:unordered? flonum-is-unordered? 2)
(flo:+ flonum-add 2)
(flo:- flonum-subtract 2)
flo:round
flo:round->exact
flo:safe-negative?
+ flo:safe-zero?
flo:safe<
flo:safe<=
flo:safe<>
+ flo:safe=
flo:safe>
flo:safe>=
flo:sin
(,subnormal+ #f)
(+1. #f)
(+inf.0 #f)
- ;; (+nan.0 #f) ; exception
- )
+ (+nan.0 #f))
(lambda (x v)
- (assert-eqv (yes-traps (lambda () (flo:zero? x))) v)))
-
-(define-test 'nan-is-not-zero
- (lambda ()
- (assert-false (no-traps (lambda () (flo:zero? (flo:nan.0)))))))
+ (assert-eqv (yes-traps (lambda () (flo:safe-zero? x))) v)))
(define-enumerated-test 'subnormal?
`((-inf.0 #f)
(define-comparison-test '>= flo:safe>= flo:>= cases)
(define-comparison-test '<= flo:safe<= flo:<= cases)
(define-comparison-test '<> flo:safe<> flo:<> cases)
+ (define-comparison-test '= flo:safe= flo:= cases)
(define-test 'unordered?
(map (lambda (x)
(map (lambda (y)
(+inf.0 #f #t)
(+nan.0 #f #f)))
+(define-constcomp-test '= flo:safe= flo:= 0.
+ `((-inf.0 #f #f)
+ (-1. #f #f)
+ (,subnormal- #f #f)
+ (-0. #t #t)
+ (+0. #t #t)
+ (,subnormal+ #f #f)
+ (+1. #f #f)
+ (+inf.0 #f #f)
+ (+nan.0 #f #f)))
+
(define-constcomp-test '<> flo:safe<> flo:<> 0.
`((-inf.0 #t #t)
(-1. #t #t)
(+inf.0 #f #t)
(+nan.0 #f #f)))
+(define-constcomp-test '= flo:safe= flo:= 1.
+ `((-inf.0 #f #f)
+ (-1. #f #f)
+ (,subnormal- #f #f)
+ (-0. #f #f)
+ (+0. #f #f)
+ (,subnormal+ #f #f)
+ (+1. #t #t)
+ (+inf.0 #f #f)
+ (+nan.0 #f #f)))
+
(define-constcomp-test '<> flo:safe<> flo:<> 1.
`((-inf.0 #t #t)
(-1. #t #t)