Re: Is infinity equal to infinity?

vosse@RULS41.FSW.LEIDENUNIV.NL (Theo Vosse)
10 Jul 1998 20:51:40 -0400

          From comp.compilers

Related articles
Is infinity equal to infinity? erikr@iar.se (Erik Runeson) (1998-07-08)
Re: Is infinity equal to infinity? vosse@RULS41.FSW.LEIDENUNIV.NL (1998-07-10)
Re: Is infinity equal to infinity? rwhutch@nr.infi.net (1998-07-10)
Re: Is infinity equal to infinity? fis@mpi-sb.mpg.de (Matthias Fischmann) (1998-07-10)
Re: Is infinity equal to infinity? john_mitchell@intuit.com (John Mitchell) (1998-07-10)
Re: Is infinity equal to infinity? joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-07-10)
Re: Is infinity equal to infinity? bear@sonic.net (Ray Dillinger) (1998-07-11)
Re: Is infinity equal to infinity? Kevin@quitt.net (1998-07-11)
[11 later articles]
| List of all articles for this month |
From: vosse@RULS41.FSW.LEIDENUNIV.NL (Theo Vosse)
Newsgroups: sci.math.num-analysis,comp.lang.c,sci.math,comp.compilers
Date: 10 Jul 1998 20:51:40 -0400
Organization: Leiden University, The Netherlands
Distribution: inet
References: 98-07-058
Keywords: arithmetic, comment

Erik Runeson <erikr@iar.se> writes:


      When comparing floating-point numbers, should infinity (Inf) be
      concidered equal to infinity?


If I remember correctly, Inf != Inf (which is completely
understandable since not all things that happen to evaluate to
infinity are equal.


You could try the following:


#include <fp.h>


int compare(double a, double b)
{
        if (FINITE(a) || FINITE(b))
        {
return (a == b);
        }
        else
        {
return (true);
        }
}


Although for the last condition you should actually check for: NaN,
+INF, -INF, and whatever else.


Theo
--
Theo Vosse
----------
Unit for Experimental Psychology
University of Leiden
The Netherlands
[The IEEE implementations I've found say that Inf == Inf. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.