﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
1157	test egg 'approx-equal?' bug?	John Foerch	Alex Shinn	"There may be a bug in 'approx-equal?' in the test egg.

I was puzzled as to why testing against an expected value of 0.0 always
seems to fail, even with a large epsilon (1.0).

    (use test)
    (test 0.0 1e-18) => [FAIL]

Here is the source code of 'approx-equal?' for reference:

    (define (approx-equal? a b epsilon)
      (cond
       ((> (abs a) (abs b))
        (approx-equal? b a epsilon))
       ((zero? b)
        (< (abs a) epsilon))
       (else
        (< (abs (/ (- a b) b)) epsilon))))

I note that the conditional branch (zero? b), which is apparently a
special case for testing against 0, will never be reached unless both a
and b are 0, because if b is 0 the absolute value of any other number is
greater, so the previous condition will catch it and flip a and b.

Should that middle condition instead be the following?

       ((zero? a)
        (< (abs b) epsilon))
"	defect	closed	major	someday	extensions	4.9.x	fixed	test		
