-
Enhancement
-
Resolution: Fixed
-
P4
-
10
The StampedLock class has some sample code with a distanceFromOrigin() method. The sample code uses
return Math.sqrt(currentX * currentX + currentY * currentY);
to compute the Euclidean distance. From a numerical perspective, this would be better computed using Math.hypot or StrictMath.hypot. The hypot method "Returns sqrt(x^2 +y^2) without intermediate overflow or underflow."
return Math.sqrt(currentX * currentX + currentY * currentY);
to compute the Euclidean distance. From a numerical perspective, this would be better computed using Math.hypot or StrictMath.hypot. The hypot method "Returns sqrt(x^2 +y^2) without intermediate overflow or underflow."