Matthew Toseland wrote: > On Tuesday 15 April 2008 09:28, Michael Rogers wrote: >> Daniel Cheng wrote: >>> 750 if(Math.abs(friendLocs[i] - myLoc) <= >>> Double.MIN_VALUE*2) continue; >> What's the purpose of this check and why does it use Math.abs instead of >> Location.distance? > > To prevent unjustified zeros when there is a race condition or other error > causing there to be two nodes with the same location (e.g. when a swap ends > up swapping with a direct peer).
If it's checking for strictly identical locations, why not use == ? Surely there's no chance of rounding errors when we're talking about two bit-for-bit copies of the same value? OTOH if it's checking for nearly-identical locations then shouldn't it use Location.distance rather than Math.abs? But either way, this check doesn't stop the product of the distances from rounding to zero if the factors are small enough - if that's the intent then why not just test whether the product is zero after leaving the loop? Cheers, Michael
