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