1750e9de4f998038c2c65ba0001b0594ac1de519
[platform/framework/web/crosswalk-tizen.git] /
1 define(['../number/MIN_INT', '../number/MAX_INT', './rand'], function(MIN_INT, MAX_INT, rand){
2
3     /**
4      * Gets random integer inside range or snap to min/max values.
5      */
6     function randInt(min, max){
7         min = min == null? MIN_INT : ~~min;
8         max = max == null? MAX_INT : ~~max;
9         // can't be max + 0.5 otherwise it will round up if `rand`
10         // returns `max` causing it to overflow range.
11         // -0.5 and + 0.49 are required to avoid bias caused by rounding
12         return Math.round( rand(min - 0.5, max + 0.499999999999) );
13     }
14
15     return randInt;
16 });