I initialize a double array:
double [] foo = new double[n];
I understand that the specification of the java language initializes all the values ββin the array to zero.
When I look through my algorithm, some of the elements in the array get a positive value.
So, to check if a particular element has a nonzero value, is it safe to just use
if (foo[i] > 0.0)
or should i use epsilon. Or similarly, if I want to know if a value is set, can I use == , given that the zeros were not calculated values, but the initial initialized zeros? Normally, of course, I would never use == to compare floating point numbers, but I wonder if this is a special case?
Thanks!
source share