UNPKG

718 BMarkdownView Raw
1# integer
2
3```js
4// usage
5chance.integer()
6chance.integer({ min: -20, max: 20 })
7```
8
9<p class="pullquote">9007199254740991 is 2^53 - 1 and is the largest number value in JavaScript</p>
10
11Return a random integer.
12
13_range: -9007199254740991 to 9007199254740991_
14
15See: [Largest number in JavaScript](http://vq.io/16qnIYj)
16
17```js
18chance.integer();
19=> -1293235
20```
21
22Can optionally provide min and max.
23
24```js
25chance.integer({ min: -20, max: 20 })
26=> -7
27```
28
29
30These min and max are inclusive, so they are included in the range. This means
31```js
32chance.integer({ min: -2, max: 2 })
33```
34would return either -2, -1, 0, 1, or 2.
35
36```js
37// Specific case
38-2 <= random number <= 2
39
40// General case
41min <= random number <= max
42```