13 Jul 1998 23:43:27 -0400

Related articles |
---|

[4 earlier articles] |

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) |

Re: Is infinity equal to infinity? dwcantrell@aol.com (1998-07-13) |

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) |

[2 later articles] |

From: | henry@spsystems.net (Henry Spencer) |

Newsgroups: | sci.math.num-analysis,comp.lang.c,sci.math,comp.compilers |

Date: | 13 Jul 1998 23:43:27 -0400 |

Organization: | SP Systems, Toronto, Canada |

Distribution: | inet |

References: | 98-07-058 |

Keywords: | arithmetic |

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", in the March 1991

issue of ACM Computing Surveys. It contains a discussion which clarifies

the somewhat cryptic initial statement of section 6.1: "Infinity

arithmetic shall be construed as the limiting case of real arithmetic with

operands of arbitrarily large magnitude, when such a limit exists." The

paper discusses 0/0 vs. 1/0, and the argument is trivially modified to

deal with comparisons.

First, a note: IEEE comparison yields one of four results -- "less than",

"equal", "greater than", and "unordered" -- and then defines at some

length how these map into true/false for various predictates. The mapping

isn't always obvious, and there are rather more useful predicates than the

conventional six.

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

paper explains this, as per the standard's terse wording, as the limit of

f(x):g(x), as x approaches some limit that makes both f(x) and g(x) go to

infinity. Just what is the limit of f(x):g(x)? Depending on what f(x)

and g(x) are, it could be "less than", "equal", or "greater than". So

there is no single limit... and that means the result of Inf:Inf must be

"unordered".

And the table on page 13 of the standard specifies that the .EQ. predicate

(one of the first six, which according to 5.7 are the ones that map into

the traditional six predicates of programming languages) yields false,

and does not cause an exception, for a comparison result of "unordered".

So (Inf==Inf) is false.

Sigh, I doubt that many compiler writers or silicon builders have gotten

this right... It's awfully subtle.

--

| Henry Spencer henry@spsystems.net

| (aka henry@zoo.toronto.edu)

--

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.