Re: Is infinity equal to infinity?

darcy@usul.CS.Berkeley.EDU (Joseph D. Darcy)
20 Jul 1998 17:00:48 -0400

          From comp.compilers

Related articles
[9 earlier articles]
Re: Is infinity equal to infinity? dwcantrell@aol.com (1998-07-13)
Re: Is infinity equal to infinity? henry@spsystems.net (1998-07-13)
Re: Is infinity equal to infinity? erikr@iar.se (Erik Runeson) (1998-07-20)
Re: Is infinity equal to infinity? larry.jones@sdrc.com (Larry Jones) (1998-07-20)
Re: Is infinity equal to infinity? darcy@usul.CS.Berkeley.EDU (1998-07-20)
Re: Is infinity equal to infinity? darcy@usul.CS.Berkeley.EDU (1998-07-20)
Re: Is infinity equal to infinity? darcy@usul.CS.Berkeley.EDU (1998-07-20)
Re: Is infinity equal to infinity? joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-07-20)
Re: Is infinity equal to infinity? miker3@ix.netcom.com (1998-07-21)
Re: Is infinity equal to infinity? dwcantrell@aol.com (1998-07-24)
| List of all articles for this month |

From: darcy@usul.CS.Berkeley.EDU (Joseph D. Darcy)
Newsgroups: sci.math.num-analysis,comp.lang.c,sci.math,comp.compilers
Date: 20 Jul 1998 17:00:48 -0400
Organization: University of California, Berkeley
Distribution: inet
References: 98-07-058 98-07-114
Keywords: arithmetic

henry@spsystems.net (Henry Spencer) writes:


>Erik Runeson <erikr@iar.se> wrote:
>>Inf == Inf ?
>>The IEEE 754 standard for floating-point arithmetics does not say
>>anything about this case...


>Actually it does, but careful reading is needed. A good resource for
>interpretation of IEEE 754 is David Goldberg's paper "What Every Computer
>Scientist Should Know About Floating-Point Arithmetic"


A postscript version of Goldberg's paper along with some commentary by
Doug Priest can be found at http://www.validgh.com/.


> [The IEEE Standard says] "Infinity arithmetic shall be construed as
> the limiting case of real arithmetic with operands of arbitrarily
> large magnitude, when such a limit exists."


...


> [Goldberg] discusses 0/0 vs. 1/0,


The limit of the ratio of two functions tending toward zero can be
arbitrary; therefore, 0/0 is NaN. However, if the numerator converges
on some non-zero value c, the ratio is +/-infinity. Therefore, in
IEEE arithmetic x/0 is +/-infinity for any finite, non-zero x.


>and the argument is trivially modified to deal with comparisons.


Unlike division, strictly speaking, comparison is not an "arithmetic"
operation as referred to the standard. Therefore, the limit argument
does not apply. (You can't construct a rational or algebraic function
giving 0 or 1 as an answer depending on if its two arguments are
equal.)


>So, what about Inf:Inf (that is, infinity compared to infinity)?


[comparing ratio of two functions with a limit of infinity at x]


>So (Inf==Inf) is false.


Even if the argument could be extended to comparison, the resulting
comparison would not be useful for floating point computation since no
value would necessarily compare equal with itself; the history of how
something was computed would need to be recorded. Floating point
numbers have finite precision and therefore lose information during
the course of a calculation. For example, if


foo = MAX_FLOAT + 1;
bar = MAX_FLOAT


then


(foo == bar) is true since 1 is rounded away during the computation of
foo. In the sort or comparison being suggested, foo would not compare
equal to bar. However, the only way record that sort of information
amounts to using arbitrarily high precision arithmetic, an expensive
approach floating point fundamentally avoids.


-Joe Darcy
darcy@cs.berkeley.edu
--


Post a followup to this message

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