All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.igumnov.common.Number Maven / Gradle / Ivy

Go to download

Common Java library - Simple, small, stable and fast library with Simplified Enterprise Server (Dependency Injection, WebServer and ORM Frameworks)

There is a newer version: 10.8
Show newest version
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