com.igumnov.common.Number Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
Common Java library - Simple, small, stable and fast library with Simplified Enterprise Server (Dependency Injection, WebServer and ORM Frameworks)
package com.igumnov.common;
import java.util.Random;
public class Number {
private static Random randomGenerator = new Random();
public static int randomIntByRange(int fromValue, int toValue) {
int bound = toValue - fromValue;
return randomGenerator.nextInt(Math.abs(bound)) + fromValue;
}
public static double randomDoubleByRange(double fromValue, double toValue) {
double bound = toValue - fromValue;
return randomGenerator.nextDouble() * Math.abs(bound) + fromValue;
}
public static long randomLongByRange(long fromValue, long toValue) {
long bound = toValue - fromValue;
return (long) (randomGenerator.nextDouble() * Math.abs(bound)) + fromValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy