List of utility methods to do Random Int
byte[] | randomByteArray(int length) Create an array of random bytes return randomByteArray(length, false, (byte) 0); |
byte[] | randomByteArray(int size, byte from, byte to) random Byte Array byte width = (byte) (to - from); byte[] result = new byte[size]; for (int i = 0; i < size; i++) result[i] = (byte) (((Math.random() * width) % width) + from); return result; |
int | randomByteAsInt() random Byte As Int return (int) (Math.random() * 0xFF); |
byte[] | randomBytes(int size) random Bytes byte[] bytes = new byte[size]; for (int index = 0; index < size; index++) { bytes[index] = (byte) randomNumber(0, 255); return bytes; |
byte[] | randomBytes(int size) random Bytes byte[] bb = bytes; byte[] ab = new byte[size]; for (int i = 0; i < size; i++) { ab[i] = randomByte(bb); return ab; |
int[] | randomCommon(int min, int max, int n) random Common if (max == min + n) { return null; if (n > (max - min + 1) || max < min) { return null; int[] result = new int[n]; int count = 0; ... |
String | randomCommonStr(int min, int max, int n) random Common Str int[] arr = randomCommon(min, max, n); String tmp = ""; for (int i = 0; i < arr.length; i++) { tmp += arr[i] + ""; return tmp; |
double[][] | randomDoubleMatrix(int rows, int columns) Creates a random matrix. double[][] matrix = new double[rows][columns]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { matrix[i][j] = Math.random(); return matrix; |
float | randomFloatInInterval(float lower, float upper) random Float In Interval return (float) (Math.random() * (Math.abs(upper - lower)) + lower); |
String | randomHex(int length) random Hex StringBuilder buf = new StringBuilder(); for (int i = 0; i < length; i++) { buf.append(Long.toHexString((long) (Math.random() * 16))); return buf.toString(); |