1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 11:18:40 +08:00

cmCTestRunTest: Simplify number width computation

Use a real logarithm implementation.
This commit is contained in:
Michael Wegner
2018-09-08 15:36:00 -07:00
committed by Brad King
parent 6a285bb737
commit 02c5091c90

View File

@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <cmath>
#include <set>
#include <stddef.h>
#include <string>
@@ -118,14 +119,7 @@ private:
inline int getNumWidth(size_t n)
{
int numWidth = 1;
if (n >= 10) {
numWidth = 2;
}
if (n >= 100) {
numWidth = 3;
}
return numWidth;
return static_cast<int>(std::log10(n)) + 1;
}
#endif