ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-dev
Jython-dev
[Jython-dev] RE: [Jython-users] (NaN == 111.0 ) returns 1 !
by Updike, Clark other posts by this author
Nov 15 2004 3:58PM messages near this date
Re: [Jython-dev] (NaN == 111.0 ) returns 1 ! | [Jython-dev] Legal usage of Jython.jar with BEA WebLogic's WLST scripting tool (built on Jython)
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 == 1
1
> >>

From the JLS:

"NaN is unordered, so the numerical comparison operators <, <=, > , and 
> = return false if either or both operands are NaN (§15.20.1). The 
equality operator == returns false if either operand is NaN, and the 
inequality operator != returns true if either operand is NaN (§15.21.1). 
In particular, x!=x is true if and only if x is NaN, and (x<y) == !(x> =y) 
will be false if x or y is NaN."

http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#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 == 111.0 ) returns 1 !

>  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. I
n this case, -1 is != 111.0, so you get back 1, representing false.

-Eric


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Jython-dev mailing list
Jython-dev@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-dev

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved