From 4d16ee4ed48ca2607be0b5a1e68562ba5f53bcc8 Mon Sep 17 00:00:00 2001 From: Sidharth Guglani Date: Tue, 5 Nov 2019 17:12:39 -0800 Subject: [PATCH] Use double for YGRoundValueToPixelGrid calculations 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 --- yoga/Yoga.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 8483dd88..016ab0ac 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -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);