You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/06/21 18:48:04 UTC
svn commit: r1352609 -
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
Author: uschindler
Date: Thu Jun 21 16:48:03 2012
New Revision: 1352609
URL: http://svn.apache.org/viewvc?rev=1352609&view=rev
Log:
LUCENE-4162: Fix infinite loop on wrong argument in MathUtil.log
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java?rev=1352609&r1=1352608&r2=1352609&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java Thu Jun 21 16:48:03 2012
@@ -27,9 +27,14 @@ public final class MathUtil {
private MathUtil() {
}
- /** returns x == 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) */
+ /**
+ * Returns {@code x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base))}
+ * @param base must be {@code > 1}
+ */
public static int log(long x, int base) {
- assert base > 1;
+ if (base <= 1) {
+ throw new IllegalArgumentException("base must be > 1");
+ }
int ret = 0;
while (x >= base) {
x /= base;