RFR: JDK-8298060: Fix precision bug in gesture recognizer classes

John Hendrikx jhendrikx at openjdk.org
Mon Dec 12 22:20:27 UTC 2022


On Mon, 12 Dec 2022 22:05:14 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/ZoomGestureRecognizer.java line 277:
>> 
>>> 275: 
>>> 276:                         if (nanosPassed > INITIAL_VELOCITY_THRESHOLD_NANOS) {
>>> 277:                             initialInertiaZoomVelocity = (totalZoomFactor - prevTotalZoomFactor) / nanosPassed * NANOS_TO_SECONDS;
>> 
>> `(totalZoomFactor - prevTotalZoomFactor) / (nanosPassed * NANOS_TO_SECONDS);` ?
>
> The order is irrelevant, it could as well be `((totalZoomFactor - prevTotalZoomFactor) / nanosPassed) * NANOS_TO_SECONDS` -- I'll let the compiler decide what is more optimal.

See other conversation, your suggestion would not be correct as it changes the order of the operations.

-------------

PR: https://git.openjdk.org/jfx/pull/966


More information about the openjfx-dev mailing list