On Thu, 27 Apr 2023 11:41:40 GMT, Kevin Rushforth <k...@openjdk.org> wrote:
>> Region has floor and ceiling functions that ensure that calling them twice >> in a row will yield the same result: >> >> ceil(x) = ceil(ceil(x)) >> >> However, due to use of a constant `EPSILON` which is added/subtracted before >> doing the rounding, this only works for small numbers (in the range of 0-50 >> approximately). For larger values and scales, rounding errors can easily >> occur. This is visible as artifacts on screen where controls are a pixel >> wider than they should be. >> >> The use of the `EPSILON` constant is incorrect, as its value depends on the >> magnitude of the value in question (as magnitude increases, the fractional >> precision decreases). >> >> The Math class offers the function `ulp` that should be used here. It >> represents the smallest possible change in value for a given double. >> >> Extending the existing test case >> `snappingASnappedValueGivesTheSameValueTest` to use larger magnitude numbers >> exposes the problems. > > @andy-goryachev-oracle can you also review this? @kevinrushforth I think this one is ready to go, and should help to already solve some of the off-by-one pixel errors for controls that are larger than 100 pixels (in any direction) that make use of the ceiling or floor functions ------------- PR Comment: https://git.openjdk.org/jfx/pull/1118#issuecomment-1556904744