Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

November/2024
SunMonTueWedThuFriSat
     12
3456789
1011121314 1516
17181920212223
24252627282930
       

[ Archives News
for 'Java Technology' ]

home > news > java technology > it all depends on what the meaning of equals equals

It All Depends on What the Meaning of Equals Equals

I found Joseph Darcy's recent post "Notions of Floating-Point Equality" interesting, informative, and even entertaining. If you've done scientific programming, you're probably familiar with the problems of floating point uncertainties, significant digits, divisions by zero that really wouldn't happen if you were doing the calculation with pencil and paper, tests of whether the values stored in two memory locations are equal, etc. It's a pain in the neck, really, dealing with these issues in a program. So, what does the == operator really mean? I'm kind of reminded of a famous quote from a former United States president. When asked a particular question, his response was: "It depends on what the meaning of the word 'is' is." So what is the meaning of is? Or of ==? Joe gets right to the point, in saying: the "==" operator defined by IEEE 754 and used by Java for comparing floating-point values (JLSv3 §15.21.1) is not an equivalence relation. Equivalence relations satisfy three properties, reflexivity (something is equivalent to itself), symmetry (if a is equivalent to b, b is equivalent to a), and transitivity (if a is equivalent to b and b is equivalent to c, then a is equivalent to c). One of the simplest tests in scientific programming for detecting numeric anomalies is to check if a value is equal to itself. Why is this useful? Because NaN (Not a Number) is not equal to itself. If ...


Date: March, 03 2010
Url: http://www.java.net/blog/editor/archive/2010/03/03/it-all-depends-what-meaning-equals-equals


Others News

©2002-2019Java-Virtual-Machine.net website designing software | free web editor | top website builder | bootstrap button | free website generator