Skip to content

Commit

Permalink
Use double for YGRoundValueToPixelGrid calculations
Browse files Browse the repository at this point in the history
Summary:
Use double for YGRoundValueToPixelGrid calculations as we were losing some precision in float operations

#Changelog:
[Internal][Yoga] Use double for YGRoundValueToPixelGrid calculations

Reviewed By: astreet

Differential Revision: D18225999

fbshipit-source-id: 69c05f56a0e0f3433bf0bd958aa07d26dd83fe02
  • Loading branch information
SidharthGuglani-zz authored and facebook-github-bot committed Nov 6, 2019
1 parent b1b97b8 commit 5ee365f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,7 @@ YOGA_EXPORT float YGRoundValueToPixelGrid(
const float pointScaleFactor,
const bool forceCeil,
const bool forceFloor) {
float scaledValue = value * pointScaleFactor;
double scaledValue = ((double) value) * pointScaleFactor;
// We want to calculate `fractial` such that `floor(scaledValue) = scaledValue
// - fractial`.
float fractial = fmodf(scaledValue, 1.0f);
Expand Down

0 comments on commit 5ee365f

Please sign in to comment.