Name: rmT116609 Date: 04/15/2004
A DESCRIPTION OF THE REQUEST :
Comparing two floating point (double) numbers value1 and value2 for equality often the following code is used:
if (Math.abs(value1 - value2) < Double.MIN_VALUE * 2)
...
I think this would not work always due to the rounding influence.
This is almost as restrictive as to use
if(value1 == value2)
...
I bellive you will need something like this:
if (Math.abs(value1 - value2) < Double.EPSILON * 2 * Math.abs(value1))
...
where Double.EPSILON is the smallest positive number x, such that x + 1.0 is not equal to 1.0 like DBL_EPSILON in C/C++.
JUSTIFICATION :
All the reasons why DBL_EPSILON and FLT_EPSILON are defined in C/C++ float.h!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
extenstion of class java.lang.Double:
static double EPSILON = 2.2204460492503131e�016;
extenstion of class java.lang.Float:
static float EPSILON = 1.192092896e�07f;
(Incident Review ID: 208014)
======================================================================