8000 Add methods to get random number with out limit. by changhe626 · Pull Request #53 · yindz/common-random · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add methods to get random number with out limit. #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/java/com/apifan/common/random/source/NumberSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ private NumberSource() {
public static NumberSource getInstance() {
return instance;
}

/**
* 返回1个随机整数
*
* @return 1个随机整数
*/
public int randomInt() {
return RandomUtils.nextInt(Integer.MIN_VALUE, Integer.MAX_VALUE);
}

/**
* 返回1个随机整数
Expand Down Expand Up @@ -55,6 +64,15 @@ public int[] randomInt(final int startInclusive, final int endExclusive, final i
}
return nums;
}

/**
* 返回1个随机长整数
*
* @return 1个随机长整数
*/
public long randomLong() {
return RandomUtils.nextLong(Long.MIN_VALUE, Long.MAX_VALUE);
}

/**
* 返回1个随机长整数
Expand Down Expand Up @@ -83,6 +101,15 @@ public long[] randomLong(final long startInclusive, final long endExclusive, fin
}
return nums;
}

/**
* 返回1个随机双精度数
*
* @return 1个随机双精度数
*/
public double randomDouble() {
return RandomUtils.nextDouble(Double.MIN_VALUE, Double.MAX_VALUE);
}

/**
* 返回1个随机双精度数
Expand Down
0