From e11d9c846e77aff52867c3c18133b7d321e09a29 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 21 Jun 2019 12:20:06 -0600 Subject: [PATCH] fix flround on [-0.5, 0.0) original commit: 9679b21d99477a077b226bc279a6d68ebbd7ce5b --- mats/5_3.ms | 2 ++ mats/fl.ms | 5 +++++ s/library.ss | 8 +++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mats/5_3.ms b/mats/5_3.ms index d8205f1b71..ca8d4b7a37 100644 --- a/mats/5_3.ms +++ b/mats/5_3.ms @@ -2186,6 +2186,8 @@ (fl= (round 0.5000000000000001) 1.0) (eqv? (round 0.0) 0.0) (eqv? (round -0.0) -0.0) + (eqv? (round -0.5) -0.0) + (eqv? (round -0.6) -1.0) ) (mat abs diff --git a/mats/fl.ms b/mats/fl.ms index d953c8f6ed..4e38a1b14b 100644 --- a/mats/fl.ms +++ b/mats/fl.ms @@ -654,6 +654,11 @@ (fl= (flround 2.5) 2.0) (fl= (flround 0.5000000000000000) 0.0) (fl= (flround 0.5000000000000001) 1.0) + (eqv? (flround 0.0) 0.0) + (eqv? (flround -0.0) -0.0) + (eqv? (flround 0.5) 0.0) + (eqv? (flround -0.5) -0.0) + (fl= (flround -0.5000000000000001) -1.0) ) (mat flinteger? diff --git a/s/library.ss b/s/library.ss index f9698506cf..f9dd164955 100644 --- a/s/library.ss +++ b/s/library.ss @@ -630,9 +630,11 @@ (if (fl< x threshold+) (fl- (fl+ x threshold+) threshold+) x) - (if (fl> x threshold-) - (fl- (fl+ x threshold-) threshold-) - x)))) + (if (fl>= x -0.5) + -0.0 ; keep negative + (if (fl> x threshold-) + (fl- (fl+ x threshold-) threshold-) + x))))) ;;; The generic comparison entries assume the fixnum case is inlined.