I have the following code:
double x = 0; { ...do stuff ...} if(x == 0){ }
I was always taught that you shouldn\'t check floats for equal
You still shouldn't check to see if it's equal to zero. Just check to see if it's near zero.
private final static double EPSILON = 0.00001; if (x + EPSILON > 0 && x - EPSILON < 0){ ... }