[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 20/58: Avoid inexact arithmetic in the type inferrer for
From: |
Andy Wingo |
Subject: |
[Guile-commits] 20/58: Avoid inexact arithmetic in the type inferrer for 'sqrt'. |
Date: |
Tue, 7 Aug 2018 06:58:31 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit fe92bc26a67c3092b64851cef06ab5a072bd705b
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 b40e48c..bac25cf 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -1668,13 +1668,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] 06/58: Make sure the return value of 'scm_crypt' is always initialized., (continued)
- [Guile-commits] 06/58: Make sure the return value of 'scm_crypt' is always initialized., Andy Wingo, 2018/08/07
- [Guile-commits] 03/58: Fix 'crypt' deadlock upon error., Andy Wingo, 2018/08/07
- [Guile-commits] 01/58: Update NEWS for 2.2.3, Andy Wingo, 2018/08/07
- [Guile-commits] 07/58: No tabs in C code., Andy Wingo, 2018/08/07
- [Guile-commits] 04/58: 'load-thunk-from-memory' reports the correct error., Andy Wingo, 2018/08/07
- [Guile-commits] 13/58: srfi-18: 'thread-sleep!' timeout-as-a-number is relative., Andy Wingo, 2018/08/07
- [Guile-commits] 18/58: Fix typo in comment within numbers.c, Andy Wingo, 2018/08/07
- [Guile-commits] 08/58: Revert "Honor '%fresh-auto-compile'.", Andy Wingo, 2018/08/07
- [Guile-commits] 15/58: Fix eta-conversion edge cases in peval., Andy Wingo, 2018/08/07
- [Guile-commits] 17/58: Fix minor typo in the PEG documentation., Andy Wingo, 2018/08/07
- [Guile-commits] 20/58: Avoid inexact arithmetic in the type inferrer for 'sqrt'.,
Andy Wingo <=
- [Guile-commits] 16/58: Fix a few typos in the manual., Andy Wingo, 2018/08/07
- [Guile-commits] 05/58: compile: Load language modules upfront., Andy Wingo, 2018/08/07
- [Guile-commits] 11/58: doc: Fix typo about SRFI-4 syntax., Andy Wingo, 2018/08/07
- [Guile-commits] 09/58: 'select' returns empty sets upon EINTR and EAGAIN., Andy Wingo, 2018/08/07
- [Guile-commits] 14/58: Recognize RISC-V compilation targets., Andy Wingo, 2018/08/07
- [Guile-commits] 21/58: goops: Fix 'instance?' to work on objects that aren't structs., Andy Wingo, 2018/08/07
- [Guile-commits] 10/58: build: Use 'sed' invocation compatible with BSD sed., Andy Wingo, 2018/08/07
- [Guile-commits] 24/58: Add copyright header for (language elisp falias), and fix typo., Andy Wingo, 2018/08/07
- [Guile-commits] 29/58: get-bytevector-n and get-bytevector-n! can now read more than 4 GB, Andy Wingo, 2018/08/07
- [Guile-commits] 26/58: tests: Add SRFI-71 test., Andy Wingo, 2018/08/07