-
Type:
Enhancement
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 10
-
Component/s: core-libs
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."