[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/08: Avoid inexact arithmetic in the type inferrer for
From: |
Mark H. Weaver |
Subject: |
[Guile-commits] 04/08: Avoid inexact arithmetic in the type inferrer for 'sqrt'. |
Date: |
Mon, 11 Jun 2018 10:22:24 -0400 (EDT) |
mhw pushed a commit to branch stable-2.2
in repository guile.
commit e1dffd35040dab4dd9f631e8c6dc9fc110f791e8
Author: Mark H Weaver <address@hidden>
Date: Sun May 27 22:04:27 2018 -0400
Avoid inexact arithmetic in the type inferrer for 'sqrt'.
* module/language/cps/types.scm: Use 'exact-integer-sqrt' and avoid
inexact arithmetic in the range analysis of the type inferrer for
'sqrt'.
---
module/language/cps/types.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 4326a8d..5c1d712 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -1512,13 +1512,16 @@ where (A0 <= A <= A1) and (B0 <= B <= B1)."
(define-type-inferrer (sqrt x result)
(let ((type (&type x)))
(cond
- ((and (zero? (logand type &complex)) (<= 0 (&min x)))
+ ((and (zero? (logand type &complex))
+ (non-negative? (&min x)))
(define! result
(logior type &flonum)
- (inexact->exact (floor (sqrt (&min x))))
+ (exact-integer-sqrt (&min x))
(if (inf? (&max x))
+inf.0
- (inexact->exact (ceiling (sqrt (&max x)))))))
+ (call-with-values (lambda () (exact-integer-sqrt (&max x)))
+ (lambda (s r)
+ (if (zero? r) s (+ s 1)))))))
(else
(define! result (logior type &flonum &complex) -inf.0 +inf.0)))))
- [Guile-commits] branch stable-2.2 updated (9a72e21 -> ac9f083), Mark H. Weaver, 2018/06/11
- [Guile-commits] 01/08: Fix typo in comment within numbers.c, Mark H. Weaver, 2018/06/11
- [Guile-commits] 05/08: goops: Fix 'instance?' to work on objects that aren't structs., Mark H. Weaver, 2018/06/11
- [Guile-commits] 06/08: Fix error reporting in 'load-thunk-from-memory'., Mark H. Weaver, 2018/06/11
- [Guile-commits] 02/08: Revert "Minor CSE run-time optimization", Mark H. Weaver, 2018/06/11
- [Guile-commits] 08/08: Add copyright header for (language elisp falias), and fix typo., Mark H. Weaver, 2018/06/11
- [Guile-commits] 07/08: elisp: Fix cross-compilation support., Mark H. Weaver, 2018/06/11
- [Guile-commits] 03/08: Fix type inference for bitwise logical operators., Mark H. Weaver, 2018/06/11
- [Guile-commits] 04/08: Avoid inexact arithmetic in the type inferrer for 'sqrt'.,
Mark H. Weaver <=