RFR: 8358820: Allow interpolation outside of range [0,1] [v2]

Joe Darcy darcy at openjdk.org
Fri Jun 27 04:54:46 UTC 2025


On Sun, 15 Jun 2025 22:02:44 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/javafx/scene/layout/region/BorderImageSlices.java line 62:
>> 
>>> 60:         Objects.requireNonNull(endValue, "endValue cannot be null");
>>> 61: 
>>> 62:         if (t == 0 || equals(endValue)) {
>> 
>> `==` on floating point could produce unexpected results since there's +0 and -0. Here it doesn't seem to matter because it's an optimization, but I see more of these in the new code, so might be worth double checking.
>
> +0 and -0 seem to be equal when using the `==` operator:
> 
> double a = 0.0;
> double b = -0.0;
> System.out.println(a == b); // prints "true"
> System.out.println(a < b); // prints "false"
> System.out.println(a > b); // prints "false"
> 
> 
> If the sign is relevant, one must use `Double.compare`:
> 
> double a = 0.0;
> double b = -0.0;
> System.out.println(Double.compare(a, b)); // prints "1"
> System.out.println(Double.compare(b, a)); // prints "-1"

Yes, IEEE 754 (and Java) require that -0.0 == +0.0 to evaluate to true.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1822#discussion_r2170776239


More information about the openjfx-dev mailing list