This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: IS_INF bug?
- To: Han-Wen Nienhuys <hanwen at cs dot uu dot nl>, Ivan Toshkov <ivant at ifao dot net>
- Subject: Re: IS_INF bug?
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Tue, 9 May 2000 15:10:33 +0200 (MEST)
- cc: Guile Mailing List <guile at sourceware dot cygnus dot com>
On Tue, 9 May 2000, Ivan Toshkov wrote:
> On Tue, May 09, 2000 at 01:19:29PM +0200, Han-Wen Nienhuys wrote:
> >
> > I think the naming of the following macro should be changed to
> > NONZERO_IS_INF, or something alike. The name is misleading.
> >
> >
> > /* IS_INF tests its floating point number for infiniteness
> > */
> > #ifndef IS_INF
> > #define IS_INF(x) ((x) == (x) / 2)
> > #endif
[...]
> If you meant that the check will work for zero, it seems that you are
> right. A (mathematically) corect test for infinity would be
> ((x) == (x) + 1) but I don't know if this makes sense for the macro.
Hello!
I just changed the test to
IS_INF(x) ((x) == (x) + 1)
so that people can experiment with it. Maybe someone feels like providing
testcases for the special case of infinite values or NaN values?
However, the whole NaN/infinity thing seems quite suspicious to me: Are
we guaranteed that the compiler will do the right thing with tests like
((x) == (x) + 1) or ((x) == (x)), as performed in 'isfinite', or might
such a test get eliminated by the compiler?
In any case, these tests are not performed very consequently throughout
numbers.c. And, guile does not offer predicates like finite?, infinite?,
not-a-number?, so if for whatever reason you would get such a value, you
couldn't even test for it.
Best regards
Dirk Herrmann