RE: [Jython-users] (NaN == 111.0 ) returns 1 ! From: Widhalm, Eric - 2004-11-15 15:33 ```> could you tell me if the following code > > >>from java.lang import Math > >>g = Math.log(-1.0) > >>print (g==111.0) > 1 > > 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 != 111.0, so you get back 1, representing false. -Eric ```
 RE: [Jython-users] (NaN == 111.0 ) returns 1 ! From: Updike, Clark - 2004-11-15 15:59 ```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=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 ```
 Re: [Jython-users] (NaN == 111.0 ) returns 1 ! From: Werner Van Belle - 2004-11-15 15:54 ```On Monday 15 November 2004 16:32, Widhalm, Eric wrote: > > could you tell me if the following code > > > > >>from java.lang import Math > > >>g = Math.log(-1.0) > > >>print (g==111.0) > > > > 1 > > > > 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 != 111.0, so you get back 1, representing false. Grunt ??? 1 = false, 0 = true ??? So if I write: print(111.0 == 111.0) it should print 0 ????? Nono, I really believe something is wrong here Werner, ```