2023-02-18 14:09:52 +00:00
|
|
|
package utils;
|
|
|
|
|
2023-02-25 17:53:42 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2023-02-18 14:09:52 +00:00
|
|
|
public class MathTools {
|
|
|
|
public static double round(double n, int places) {
|
|
|
|
return (Math.round(n * Math.pow(10, places))) / Math.pow(10, places);
|
|
|
|
}
|
2023-02-25 17:53:42 +00:00
|
|
|
|
|
|
|
public static double random(double minLimit, double maxLimit) {
|
|
|
|
Random rand = new Random();
|
|
|
|
return rand.nextDouble(minLimit, maxLimit);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isNumPrime(int n) {
|
|
|
|
if (n <= 1)
|
|
|
|
return false;
|
|
|
|
for (int i = 2; i < n; i++)
|
|
|
|
if (n % i == 0)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
2023-02-18 14:09:52 +00:00
|
|
|
}
|