Math.floor operation on MeasureOutput for Java and C# #296
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I just wanted to check if this behavior was by-design before I made any PR. In react-native-windows, we have to do Math.Ceiling on all of our measure function outputs because casting from float/double to int always does a floor operation:
https://github.com/facebook/yoga/blob/master/csharp/Facebook.Yoga/MeasureOutput.cs#L16
https://github.com/facebook/yoga/blob/master/java/com/facebook/yoga/YogaMeasureOutput.java#L18
I imagine this isn't a problem for react-native on Android because they don't encounter fractional pixel dimensions?
Nice catch! But I think we should not use any rounding logic as those values are treated as float in the c part.
For Java we could instead use:
In C#:
As this is a little cumbersome on C# maybe its better to use directly a struct with two floats (see YGSize)?
This additionally prevents us from a bug if we calculate a size bigger than 16777216 as this would overflow into the exponent part.
@emilsjolander Java still needs to be changed/fixed.
@woehrl01 putting up an internal diff for java now. thanks!
352f592767