You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2018/09/19 12:18:56 UTC
svn commit: r1841321 - in /poi/trunk/src:
java/org/apache/poi/ss/formula/atp/RandBetween.java
testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java
Author: fanningpj
Date: Wed Sep 19 12:18:56 2018
New Revision: 1841321
URL: http://svn.apache.org/viewvc?rev=1841321&view=rev
Log:
[bug-62738] make int cast a long cast in randbetween
Modified:
poi/trunk/src/java/org/apache/poi/ss/formula/atp/RandBetween.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/RandBetween.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/RandBetween.java?rev=1841321&r1=1841320&r2=1841321&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/RandBetween.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/RandBetween.java Wed Sep 19 12:18:56 2018
@@ -77,7 +77,7 @@ final class RandBetween implements FreeR
top = bottom;
}
- return new NumberEval((bottom + (int)(Math.random() * ((top - bottom) + 1))));
+ return new NumberEval((bottom + (long)(Math.random() * ((top - bottom) + 1))));
}
Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java?rev=1841321&r1=1841320&r2=1841321&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java Wed Sep 19 12:18:56 2018
@@ -53,12 +53,6 @@ public class TestRandBetween extends Tes
formulaCell = row.createCell(2, CellType.FORMULA);
}
- @Override
- protected void tearDown() throws Exception {
- // TODO Auto-generated method stub
- super.tearDown();
- }
-
/**
* Check where values are the same
*/
@@ -74,6 +68,17 @@ public class TestRandBetween extends Tes
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
}
+
+ public void testRandBetweenLargeLongs() {
+ for (int i = 0; i < 100; i++) {
+ evaluator.clearAllCachedResultValues();
+ formulaCell.setCellFormula("RANDBETWEEN(0,9999999999)");
+ evaluator.evaluateFormulaCell(formulaCell);
+ double value = formulaCell.getNumericCellValue();
+ assertTrue("rand is greater than or equal to lowerbound", value >= 0.0);
+ assertTrue("rand is less than or equal to upperbound", value <= 9999999999.0);
+ }
+ }
/**
* Check special case where rounded up bottom value is greater than
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org