13 Jul 1998 23:42:26 -0400

Related articles |
---|

[3 earlier articles] |

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

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

[3 later articles] |

From: | dwcantrell@aol.com (DWCantrell) |

Newsgroups: | comp.compilers |

Date: | 13 Jul 1998 23:42:26 -0400 |

Organization: | AOL http://www.aol.com |

References: | 98-07-090 |

Keywords: | arithmetic |

Erik Runeson wrote:

*>>*

*>> When comparing floating-point numbers, should infinity (Inf) be*

*>> concidered equal to infinity?*

*>>*

*>> Inf == Inf ?*

Joachim Durchholz <joachim.durchholz@munich.netsurf.de> writes:

*>This depends on what infinity you have.*

*>For example, Intel x87 floating-point arithmetic has the following*

*>infinities:*

*> 1/0 positive infinity*

*> -1/0, log(0) negative infinity*

*>These may compare equal to each other or not, depending on the mode the*

*>chip is in: in "affine" mode, they are different, in "projective" mode,*

*>they are considered equal.*

You raise an interesting point. ANSI/IEEE standard 754-1985 does not

mention a projective mode, although both modes were required in some

drafts of the standard. I think it is unfortunate that the projective

mode was dropped from the final version. Curiously the projective mode

was to have been "the default because it is less likely to be abused

unwittingly." [Coonen, commenting on a draft of the standard,

_Computer_, 13:1, p. 73]

Mathematically speaking, there is just one improper element oo

adjoined to the real numbers when producing the one-point

compactification. It has the property that -(oo) = oo. Although it is

unordered with respect to all real numbers, oo = oo is TRUE.

The drafts of the standard specifying projective mode in essence

allowed the oo of the one-point compactification: by *identifying* +oo

and -oo, so that -oo = +oo, there was then really just one

infinity. And [ibid., p. 78] clearly that infinity was to be

considered equal to itself, but unordered with respect to finite

numbers.

*>(There is a range of numbers called "indefinite" that result from things*

*>like 0/0, sqrt(-1), or log(-1).*

In the standard, the name NaN (for "Not a Number") is used.

*>These are nevery considered equal to an infinity;*

True.

*>I don't know how they compare to each other. MS C++ has an*

*>_isnan() function that checks for infinities and indetermates.)*

In the standard, NaNs are unordered with respect to each other. I

don't know about MS C++; but an appendix to the standard recommends

that isnan(x) return TRUE if x is a NaN and return FALSE

otherwise. Infinities are not NaNs, and thus isnan(x) should not be

used to check for infinities. Instead the appendix gives finite(x),

which returns the value TRUE if -oo < x < +oo and FALSE otherwise.

Cheers,

David Cantrell

--

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.