mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
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'.
This commit is contained in:
parent
c6f6edcc50
commit
fe92bc26a6
1 changed files with 6 additions and 3 deletions
|
@ -1668,13 +1668,16 @@ where (A0 <= A <= A1) and (B0 <= B <= B1)."
|
||||||
(define-type-inferrer (sqrt x result)
|
(define-type-inferrer (sqrt x result)
|
||||||
(let ((type (&type x)))
|
(let ((type (&type x)))
|
||||||
(cond
|
(cond
|
||||||
((and (zero? (logand type &complex)) (<= 0 (&min x)))
|
((and (zero? (logand type &complex))
|
||||||
|
(non-negative? (&min x)))
|
||||||
(define! result
|
(define! result
|
||||||
(logior type &flonum)
|
(logior type &flonum)
|
||||||
(inexact->exact (floor (sqrt (&min x))))
|
(exact-integer-sqrt (&min x))
|
||||||
(if (inf? (&max x))
|
(if (inf? (&max x))
|
||||||
+inf.0
|
+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
|
(else
|
||||||
(define! result (logior type &flonum &complex) -inf.0 +inf.0)))))
|
(define! result (logior type &flonum &complex) -inf.0 +inf.0)))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue