Browse Source

Merge topic 'ctest-num-width'

6d28884617 cmCTestRunTest: Avoid float/int conversions in number width logic

Acked-by: Kitware Robot <[email protected]>
Merge-request: !2433
Brad King 7 years ago
parent
commit
0b1b842e93
1 changed files with 6 additions and 2 deletions
  1. 6 2
      Source/CTest/cmCTestRunTest.h

+ 6 - 2
Source/CTest/cmCTestRunTest.h

@@ -5,7 +5,6 @@
 
 #include "cmConfigure.h" // IWYU pragma: keep
 
-#include <cmath>
 #include <set>
 #include <stddef.h>
 #include <string>
@@ -122,7 +121,12 @@ private:
 
 inline int getNumWidth(size_t n)
 {
-  return static_cast<int>(std::log10(n)) + 1;
+  int w = 1;
+  while (n >= 10) {
+    n /= 10;
+    ++w;
+  }
+  return w;
 }
 
 #endif