This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
infinity != infinity
- From: Joern Rennecke <joern dot rennecke at superh dot com>
- To: paolo dot bonzini at polimi dot it (Paolo Bonzini)
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 9 Jul 2004 22:06:53 +0100 (BST)
- Subject: infinity != infinity
Your test execute/ieee/compare-fp-1.c says:
iungt (pinf, pinf, 0);
iungt (ninf, ninf, 0);
However, as I interpret ieee 754, +inf compares unorderd to +inf,
and likewise -inf compares unordered to -inf.
6.1 Says that that infinity arithmetic shall be construed as the limiting
case of real aritmetic of arbitrary large magnitude, where such a limit
exists.
Since both sides of the comparison are typically computed independently,
such a limit only exists if you could apply the limit operations
independently in either order, or simultanously, and get the same result.
However,
compare(+infinity, n)
lim n
0 -> +infinity
is greater, while
compare(n, +infinity)
lim n
0 -> +infinity
is less,
compare(n, n)
lim n
0 -> +infinity
is equal, and
compare(3 * n, (3 * n) XOR 1)
lim n
0 -> +infinity
does not even converge.
Likewide for compare (-infinity,-infinity).
Thus, two infinities with the same sign should compare unordered.
This is also consistent with their difference being a NaN.