This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: IS_INF bug?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]