I don't quite get your meaning, but maybe this is clearer:
Jython 2.1 on java1.3.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> from java.lang.Float import NaN
>>> NaN =3D=3D 1
1
>>>
From the JLS:
"NaN is unordered, so the numerical comparison operators <, <=3D, >, and =
>=3D return false if either or both operands are NaN (=A715.20.1). The=20
equality operator =3D=3D returns false if either operand is NaN, and the =
inequality operator !=3D returns true if either operand is NaN =
(=A715.21.1).=20
In particular, x!=3Dx is true if and only if x is NaN, and (x<y) =3D=3D =
!(x>=3Dy)=20
will be false if x or y is NaN."
http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.ht=
ml#16083
a.k.a. Bug, IMHO.
-Clark
-----Original Message-----
From: On Behalf Of Widhalm, Eric
Sent: Monday, November 15, 2004 10:32 AM
Subject: RE: [Jython-users] (NaN =3D=3D 111.0 ) returns 1 !
> could you tell me if the following code
>=20
> >>from java.lang import Math
> >>g =3D Math.log(-1.0)
> >>print (g=3D=3D111.0)
> 1
>=20
> highlights a bug or is an (un)expected behaviour of the rich
> comparison?
Nicola, the return value will either be 0 or 1, representing boolean =
values true or false. In this case, -1 is !=3D 111.0, so you get back 1, =
representing false.
-Eric
|