Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
修复随机函数bug
Browse files Browse the repository at this point in the history
  • Loading branch information
easepan committed Apr 2, 2018
1 parent 46dd909 commit 913f017
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/zhazhapan/util/RandomUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ public static int getRandomIntegerIgnoreRange(int floor, int ceil, int[]... rang
int result = getRandomInteger(floor, ceil);
for (int[] range : ranges) {
if (range[0] <= result && result <= range[1]) {
result = result - 1 - (range[1] - range[0]);
break;
if (range[0] > floor) {
result = getRandomIntegerIgnoreRange(floor, range[0], ranges);
} else if (range[1] < ceil) {
result = getRandomIntegerIgnoreRange(range[1], ceil, ranges);
} else {
return -1;
}
}
}
return result;
Expand Down

0 comments on commit 913f017

Please sign in to comment.