bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'isfinite'


From: Bruno Haible
Subject: Re: new module 'isfinite'
Date: Wed, 24 Oct 2007 12:51:45 +0200
User-agent: KMail/1.5.4

Hi Ben,

Paul Eggert wrote:
> >         * Is it acceptable for isfinite to raise an exception on
> >           a signaling NaN?
> 
> Yes.

I disagree. We know what the relevant standards say: [1]
Also there is the issue with numbers outside the IEEE spec: [2]
Since this is a classification function, IMO it must not raise an exception,
since this function is often used like this:

  double foo (double x)
  {
    if (!isfinite (x))
      return x;
    ...
  }

Since the only function in gnulib so far that can reliably sort out
signalling NaNs and non-IEEE numbers without exception is isnan*(), IMO
gl_isfinite* needs to use this function. Like this:

int gl_isfinitef (float x)
{
  return !isnanf (x) && (x + x == x || x == 0.0f);
}

Or, using Paul's idea:

int gl_isfinitef (float x)
{
  return !isnanf (x) && (x - x == 0.0f);
}

Bruno


[1] http://lists.gnu.org/archive/html/bug-gnulib/2007-03/msg00396.html
[2] http://lists.gnu.org/archive/html/bug-gnulib/2007-06/msg00040.html





reply via email to

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