mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
Fixing inexact comparisons to handle different signed arguments.
This commit is contained in:
parent
77cf790158
commit
a49907b9b6
1 changed files with 7 additions and 2 deletions
|
@ -244,8 +244,13 @@
|
|||
(else #f)))
|
||||
|
||||
(define (approx-equal? a b epsilon)
|
||||
(< (abs (- 1 (abs (if (zero? b) (+ 1 a) (/ a b)))))
|
||||
epsilon))
|
||||
(cond
|
||||
((> (abs a) (abs b))
|
||||
(approx-equal? b a epsilon))
|
||||
((zero? b)
|
||||
(< (abs a) epsilon))
|
||||
(else
|
||||
(< (abs (/ (- a b) b)) epsilon))))
|
||||
|
||||
(define (call-with-output-string proc)
|
||||
(let ((out (open-output-string)))
|
||||
|
|
Loading…
Add table
Reference in a new issue