This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch improve_util_numdigits in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit 386dfc271f3f742018304d6164c925074daaa809 Author: Lee Rhodes <[email protected]> AuthorDate: Sun Sep 13 12:04:17 2026 -0700 Remove temp numDigits & test methods. --- src/main/java/org/apache/datasketches/common/Util.java | 18 ------------------ .../java/org/apache/datasketches/common/UtilTest.java | 18 ------------------ 2 files changed, 36 deletions(-) diff --git a/src/main/java/org/apache/datasketches/common/Util.java b/src/main/java/org/apache/datasketches/common/Util.java index 42f28b427..8412fd24c 100644 --- a/src/main/java/org/apache/datasketches/common/Util.java +++ b/src/main/java/org/apache/datasketches/common/Util.java @@ -807,24 +807,6 @@ public final class Util { return (int) ceil(log(n) / log(10)); } - /** - * Computes the minimum number of characters required to print the number n as a decimal. - * Negative numbers add one for the minus sign character. - * No other non-digit characters are assumed. - * @param n the given number, which may be negative. - * @return the number of characters required to print the number n - */ - public static int numDigits2(long n) { - if (n == 0) { return 1; } // handles the zero special case - int count = (n < 0) ? 1 : 0; // handles the minus sign - while (n != 0) { - n /= 10; - count++; - } - return count; - } - - /** Generic relational tests *****************/ /** diff --git a/src/test/java/org/apache/datasketches/common/UtilTest.java b/src/test/java/org/apache/datasketches/common/UtilTest.java index 22f20e274..ca6445b3a 100644 --- a/src/test/java/org/apache/datasketches/common/UtilTest.java +++ b/src/test/java/org/apache/datasketches/common/UtilTest.java @@ -46,7 +46,6 @@ import static org.apache.datasketches.common.Util.isPowerOf2; import static org.apache.datasketches.common.Util.longToBytes; import static org.apache.datasketches.common.Util.milliSecToString; import static org.apache.datasketches.common.Util.nanoSecToString; -import static org.apache.datasketches.common.Util.numDigits2; import static org.apache.datasketches.common.Util.numberOfLeadingOnes; import static org.apache.datasketches.common.Util.numberOfTrailingOnes; import static org.apache.datasketches.common.Util.powerSeriesNextDouble; @@ -434,23 +433,6 @@ public class UtilTest { assertEquals(v, v2); } - @Test - static void checkNumDigits() { - for (long n = 1; n < Long.MAX_VALUE && n > 0; n *= 10) { - checkN(n); - checkN(n - 1); - checkN(-n); - checkN(-n + 1); - } - checkN(Long.MAX_VALUE); - checkN(Long.MIN_VALUE); - } - - private static void checkN(long n) { - //println(n); - assertEquals(numDigits2(n), String.valueOf(n).length()); - } - @Test public void printlnTest() { println("PRINTING: " + this.getClass().getName()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
