MCPcopy Create free account
hub / github.com/DiUS/java-faker / randomNumber

Method randomNumber

src/main/java/com/github/javafaker/Number.java:55–63  ·  view source on GitHub ↗

@param numberOfDigits the number of digits the generated value should have @param strict whether or not the generated value should have exactly numberOfDigits

(int numberOfDigits, boolean strict)

Source from the content-addressed store, hash-verified

53 * @param strict whether or not the generated value should have exactly <code>numberOfDigits</code>
54 */
55 public long randomNumber(int numberOfDigits, boolean strict) {
56 long max = (long) Math.pow(10, numberOfDigits);
57 if (strict) {
58 long min = (long) Math.pow(10, numberOfDigits - 1);
59 return faker.random().nextLong(max - min) + min;
60 }
61
62 return faker.random().nextLong(max);
63 }
64
65 /**
66 * Returns a random number

Calls 3

decimalBetweenMethod · 0.95
nextLongMethod · 0.80
randomMethod · 0.45