I have some code like this:
class Foo { public double x; } void test() { Foo foo = new Foo(); // Is this a valid way to test for zero? \'x\' ha
The safest way would be bitwise OR ing your double with 0. Look at this XORing two doubles in Java
Basically you should do if ((Double.doubleToRawLongBits(foo.x) | 0 ) ) (if it is really 0)
if ((Double.doubleToRawLongBits(foo.x) | 0 ) )