chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #935: test egg's approx-equal? cannot distinguish -1.


From: Chicken Trac
Subject: [Chicken-janitors] #935: test egg's approx-equal? cannot distinguish -1. and 1.
Date: Thu, 18 Oct 2012 15:23:40 -0000

#935: test egg's approx-equal? cannot distinguish -1. and 1.
------------------------+---------------------------------------------------
 Reporter:  alaric      |       Owner:  foof   
     Type:  defect      |      Status:  new    
 Priority:  major       |   Milestone:  someday
Component:  extensions  |     Version:  4.8.x  
 Keywords:  test        |  
------------------------+---------------------------------------------------
 {{{
 #;1> (define (approx-equal? a b epsilon)
 >  (< (abs (- 1 (abs (if (zero? b) (+ 1 a) (/ a b)))))
 >    epsilon))
 #;2> (approx-equal? -1. 1. 1e-05)
 #t
 }}}

 Looking at the code, the problem is clear: the inner abs destroys the
 difference between 1. (a and b are near-identical) and -1. (a and b are
 near-identical apart from differing signs), and should be removed:

 {{{
 (define (approx-equal? a b epsilon)
   (< (abs (- 1 (if (zero? b) (+ 1 a) (/ a b))))
     epsilon))
 }}}

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/935>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]