la4j
la4j copied to clipboard
It is not nessesary to compare dobles with zero using EPS
It looks like we don't need to use EPS while comparing doubles with zero. So, we can rewrite all the following cases:
if (Math.abs(value) > Matrices.EPS) { // not a zero
...
}
if (Math.abs(value) < Matrices.EPS) { // zero
...
}
to
if (value != 0.0) { // not a zero
...
}
if (value == 0.0) { // zero
}
But we stiil need EPS while comapring two doubles.
Can value != (double)0.0
and value != 0.0
give different results?
I dont' think so. The javac
should parse 0.0 as double literal.
double x = Matrices.EPS / 20;
System.out.println(x == 0.0);
System.out.println(Math.abs(x) < Matrices.EPS);
gives
false
true
Ok, I will move it to the next milestone. We will think about it more.
Moving to the next milestone.