[rrd-developers] Re: Representation of NAN and INF

Matt Zimmerman mdz at debian.org
Thu Jul 26 04:13:54 MEST 2001


On Wed, Jul 25, 2001 at 04:54:25PM +0200, Alex van den Bogaerdt wrote:

> Dan McGinn-Combs wrote:
> 
> > I note in the C source that these two pseudo-numbers have representation
> > defined in terms of the particular float scheme used with the C compiler:
> > 
> > #define DNAN    ((double)(0.0/0.0))
> > #define DINF    ((double)(1.0/0.0))
> > 
> > Apparently, these two representations come out different. However, in the
> > math I studied, "anything" divided by 0 is still ... like Undefined. And so
> > 0/0 is the same as 1/0 and both are illegal.
> 
> For real mathematics this statement is entirely true.  However, in C
> there is some IEEE standard that defines the float (and double) number
> format and I *think* (so: not sure) this also defines the behaviour
> when dividing by zero.

Mathematically speaking, 1.0/0.0 is undefined while 0.0/0.0 is indeterminate,
and those do not mean the same thing.  From a programming standards
perspective, as far as I know, IEEE 754 says that there are multiple
permissible representations for NaN and infinity (not all bits are defined).
So there are values for which, within rrdtool:

isnan(x) && x != DNAN
and
isinf(x) && x != DINF

I would hope that rrdtool only uses these macros to obtain reasonable values to
use in its internal storage format, and not for any comparisons (where the IEEE
functions should be used).

As long as this is true, the expressions for DNAN and DINF are a perfectly
valid way to obtain some values which will satisfy finite/isnan/isinf in the
expected ways:  IEEE defines that isnan(0.0/0.0) and isinf(1.0/0.0) will both
be true.

I missed the original post...is there some compiler which is not handling these
expressions correctly?

-- 
 - mdz


--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-developers mailing list