I know we can\'t compare 2 floating point values using ==. We can only compare they are within some interval of each other. I know
if(val == 0.512)
For comparison with err all you need to is.
// compare a and b with an ERR error. if (Math.abs(a - b) <= ERR)
To compare with 0
// compare a and 0 with an ERR error. if (Math.abs(a) <= ERR)
I would still recommend following the tolerance idiom and not compare to zero exactly.