why abs at all?
if (tree[ii].distance >= 1.0) tree[ii].distance = -1.0;
seems perfectly fine (no need to add epsilon either way)