IBPCollectionViewCompositionalLayout icon indicating copy to clipboard operation
IBPCollectionViewCompositionalLayout copied to clipboard

Floating Point issues

Open notjosh opened this issue 6 years ago • 3 comments

Whew, this one was a tricky one, and probably a bigger issue to address (there are a lot of float comparisons!), so I'm interested in your thoughts.

The comparison here was causing a layout issue for me, where an orthogonal view wasn't moving down below the header (boundary supplementary) view.

I was getting these values:

(lldb) p itemFrame
(CGRect) $6 = (origin = (x = 0, y = 314.66666666666669), size = (width = 414, height = 58))
(lldb) p frame 
(CGRect) $7 = (origin = (x = 0, y = 314.66666666666663), size = (width = 414, height = 256.66666666666669))

Obviously in UI coordinates, 314.66666666666669 is the same as 314.66666666666663, but the comparison failed.

How do you think we should handle comparisons like this across the lib?

notjosh avatar Sep 05 '19 01:09 notjosh

My quick workaround was this, fyi: https://github.com/notjosh/IBPCollectionViewCompositionalLayout/commit/f8995b313e56f0700521872f993dd3c8bdb049bb

notjosh avatar Sep 05 '19 01:09 notjosh

Thank you for reporting the issue. I'll look into it this weekend.

kishikawakatsumi avatar Sep 05 '19 02:09 kishikawakatsumi

Floating-point values ​​should eventually be rounded to screen scale. It should be delayed as much as possible to minimize the round-ff error.

I'm aware of this issue and it should be fixed, but it's a project-wide issue and I haven't started work.

kishikawakatsumi avatar Sep 16 '19 15:09 kishikawakatsumi