Need to use compareTo when comparing BigIntegers, otherwise get a string comparison with lexical order

This commit is contained in:
Bart Butler 2015-02-08 21:20:07 -08:00
parent 168b184a1a
commit 0ce32bec92

View File

@ -124,7 +124,7 @@ module.exports = {
var range = max.subtract(min); var range = max.subtract(min);
var r = this.getRandomBigInteger(range.bitLength()); var r = this.getRandomBigInteger(range.bitLength());
while (r > range) { while (r.compareTo(range) > 0) {
r = this.getRandomBigInteger(range.bitLength()); r = this.getRandomBigInteger(range.bitLength());
} }
return min.add(r); return min.add(r);