From 6d288846178a1b75e9d50578d710265516ce8f82 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 2 Oct 2018 15:09:12 -0400 Subject: cmCTestRunTest: Avoid float/int conversions in number width logic Use of `std::log10` added by commit 02c5091c90 (cmCTestRunTest: Simplify number width computation, 2018-09-08) broke our number width computation on some platforms where static_cast(std::log10(static_cast(10))) somehow produces `0` instead of `1`. Re-implement the logic to avoid floating-point computations. --- Source/CTest/cmCTestRunTest.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index 48a5064..10dceca 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -5,7 +5,6 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include #include #include #include @@ -122,7 +121,12 @@ private: inline int getNumWidth(size_t n) { - return static_cast(std::log10(n)) + 1; + int w = 1; + while (n >= 10) { + n /= 10; + ++w; + } + return w; } #endif -- cgit v0.12