Mark Dickinson <[EMAIL PROTECTED]> writes: > Any change to Python that made == and != checks involving NaNs raise > an exception would have to consider the consequences for set, dict, > list membership testing. > > > and if Python had separate operators for these two purposes it > wouldn't be Python any more.
There are separate Python operators, "==" and "is". The C99 standard, which Python defers to for its implementation, says in 6.2.6.1.4: Two values (other than NaNs) with the same object representation compare equal, but values that compare equal may have different object representations. In 7.12.13, the fmax and fmin functions treat NaNs as missing arguments. Most other operations return NaN if an argument is NaN, or for a domain error. 7.12.14 specifies comparison macros that are quiet versions of the relational operators. BTW floating-point exceptions in C and IEEE are not the same as exceptions in higher level languages. The behavior of signalling NaNs are not defined in C. Only quiet NaNs are returned from operations. An invalid floating-point exception may well just set a status flag. That may be tested after a set of calculations. With pipelining the exact cause of the exception will be unknown. -- Pete Forman -./\.- Disclaimer: This post is originated WesternGeco -./\.- by myself and does not represent [EMAIL PROTECTED] -./\.- the opinion of Schlumberger or http://petef.port5.com -./\.- WesternGeco. -- http://mail.python.org/mailman/listinfo/python-list