From a626bf3ceb8504fffea39ac29fdba27f2be9ca25 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 7 Dec 2018 04:16:41 +0000 Subject: [PATCH] Make flo:nan.0 reliably return a `positive' quiet NaN with payload 0. --- src/runtime/floenv.scm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/runtime/floenv.scm b/src/runtime/floenv.scm index f3985562d..5fe50699b 100644 --- a/src/runtime/floenv.scm +++ b/src/runtime/floenv.scm @@ -365,7 +365,9 @@ USA. (flo:untrap-exceptions! exceptions) (procedure)))) -(define flo:nan.0) +(define (flo:nan.0) + (flo:make-nan #f #t 0)) + (define flo:+inf.0) (define flo:-inf.0) ;;; ZERO can be eliminated after 9.3 is released. It works around @@ -373,11 +375,6 @@ USA. (let ((zero (lambda () (identity-procedure 0.)))) (if (flo:have-trap-enable/disable?) (begin - (set! flo:nan.0 - (named-lambda (flo:nan.0) - (flo:with-exceptions-untrapped (flo:exception:invalid-operation) - (lambda () - (flo:/ 0. (zero)))))) (set! flo:+inf.0 (named-lambda (flo:+inf.0) (flo:with-exceptions-untrapped (flo:exception:divide-by-zero) @@ -391,7 +388,6 @@ USA. unspecific) ;; This works on macOS. YMMV. (begin - (set! flo:nan.0 (named-lambda (flo:nan.0) (flo:/ 0. (zero)))) (set! flo:+inf.0 (named-lambda (flo:+inf.0) (flo:/ +1. (zero)))) (set! flo:-inf.0 (named-lambda (flo:-inf.0) (flo:/ -1. (zero)))) unspecific))) \ No newline at end of file -- 2.25.1