From cb6e76973d4b7d66525188bdcd81c60d9a7d2a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Wed, 4 Apr 2018 06:42:36 -0700 Subject: [PATCH] Fix float type mismatch on endOfLineIndex and inside rounding Summary: This PR fixes a type mismatch on `endOfLineIndex` where it should be of type `uint32_t` while it is of type `float` Additonally it fixes some `double` casting in the rounding methods. Closes https://github.com/facebook/yoga/pull/745 Differential Revision: D7494519 Pulled By: emilsjolander fbshipit-source-id: 30a86574ce163458a6888f61a902d0640c1874fb --- yoga/Utils.h | 2 +- yoga/Yoga.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/yoga/Utils.h b/yoga/Utils.h index 1de614ce..ce45e348 100644 --- a/yoga/Utils.h +++ b/yoga/Utils.h @@ -40,7 +40,7 @@ struct YGCollectFlexItemsRowValues { float sizeConsumedOnCurrentLine; float totalFlexGrowFactors; float totalFlexShrinkScaledFactors; - float endOfLineIndex; + uint32_t endOfLineIndex; std::vector relativeChildren; float remainingFreeSpace; // The size of the mainDim for the row after considering size, padding, margin diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index af5b2b41..0dba6565 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -3368,12 +3368,12 @@ float YGRoundValueToPixelGrid(const float value, const bool forceCeil, const bool forceFloor) { float scaledValue = value * pointScaleFactor; - float fractial = fmodf(scaledValue, 1.0); + float fractial = fmodf(scaledValue, 1.0f); if (YGFloatsEqual(fractial, 0)) { // First we check if the value is already rounded scaledValue = scaledValue - fractial; - } else if (YGFloatsEqual(fractial, 1.0)) { - scaledValue = scaledValue - fractial + 1.0; + } else if (YGFloatsEqual(fractial, 1.0f)) { + scaledValue = scaledValue - fractial + 1.0f; } else if (forceCeil) { // Next we check if we need to use forced rounding scaledValue = scaledValue - fractial + 1.0f;