From c5c419e55a3e4d77d431faf18f7b5e2284933bb1 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 9 Feb 2021 10:20:54 -0600 Subject: [PATCH] LGTM: Eliminate float-to-double overflow warning LGTM complains if this calculation is done from inside the sqrt() call because it sees the explicit cast to float and assumes that sqrt() is intended to take a double. By adding an intermediate step it should be clear to LGTM that the float version of sqrt is intended. --- src/Mod/Mesh/App/Core/Grid.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Mesh/App/Core/Grid.cpp b/src/Mod/Mesh/App/Core/Grid.cpp index 336f713776..4bbc1ce337 100644 --- a/src/Mod/Mesh/App/Core/Grid.cpp +++ b/src/Mod/Mesh/App/Core/Grid.cpp @@ -291,7 +291,8 @@ void MeshGrid::CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxG else fAreaElem = fArea / float(_ulCtElements); - fGridLen = sqrt(fAreaElem * float(ulCtGrid)); + float fRepresentativeArea = fAreaElem * static_cast(ulCtGrid); + fGridLen = sqrt(fRepresentativeArea); } if (fGridLen > 0) {