0.0d == 0.0d + Double.MIN_VALUE returns true

From: Murat Tasan (tasan_at_eecs.cwru.edu)
Date: 04/27/04


Date: Tue, 27 Apr 2004 16:44:21 -0400

so i'm having a slight problem, and i've already looked at the java
language spec which forwarded me to the ieee floating point computation
spec that java uses, but none of those sources really offers me a decent
solution.

the problem is summarized in the subject line:

if you add Double.MIN_VALUE to a double, they are still considered equal
in a comparison.

given a double, i need to find the next smallest double that will result
in a value that is considered distinct to the == operator (and thus also
the <=, <, >, >= operators).
i can just sit and do binary additions to the value and compare each time,
but this will grind my application to a halt.

has anyone else ever had a problem with this and found a nice solution
around it?

thanks,

murat

-- 
Murat Tasan
mxt6@po.cwru.edu
tasan@eecs.cwru.edu
murat.tasan@cwru.edu
http://genomics.cwru.edu


Relevant Pages

  • Re: C#, without knee-jerk panic
    ... >> They do an incredible job of keeping all of the information ... Java background, and even easier if you come from a Java/C/C++ background), ... Java job knowing only the Java language spec while having never touched ...
    (comp.lang.java.programmer)
  • Re: 0.0d == 0.0d + Double.MIN_VALUE returns true
    ... okay, the subject line example does evaluate to false... ... On Tue, 27 Apr 2004, Murat Tasan wrote: ... > language spec which forwarded me to the ieee floating point computation ...
    (comp.lang.java)
  • another design question, abstract static methods...
    ... so here is another general question about java... ... why can't you declare an abstract static method. ... i can envision the case where one ... Murat Tasan ...
    (comp.lang.java)
  • Re: main() return type convention [was Re: Linux compiling]
    ... "Anthony Borla" wrote in message ... whilst Java enforces a 'void' returning 'main'. ... I should have checked the language spec *before* I posted, ... personal practice [my C# code uses a 'void'-returning 'Main' ala Java]. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: two methods with different result type
    ... the language spec is quite clear forbidding it. ... Roedy Green Canadian Mind Products ... The Java Glossary ...
    (comp.lang.java.programmer)