Nodejs Random Number Get iRandom(a, b)

Here you can find the source of iRandom(a, b)

Method Source Code

Math.iRandom = function(a, b){
   if (arguments.length == 1){
      return Math.round(Math.random() * a);
   }else if (arguments.length == 2){
      return a + Math.round(Math.random() * (b - a));
   }/*  ww  w . ja va 2s. c o m*/
};

Related

  1. rand(l, u)
    Math.rand = function (l, u) {
      return Math.floor((Math.random() * (u - l + 1)) + l);
    };
    
  2. rand(min, max)
    Math.rand = function(min, max) { 
      return Math.floor(Math.random() * (max - min) + min); 
    
  3. range(a, b)
    Math.range = function (a, b) {
      return this.floor(this.random() * a) + b;
    };
    
  4. random(_minNum,_maxNum,_rejArr)
     function random(_minNum,_maxNum,_rejArr){
         var minNum=_minNum||4,
             maxNum=_maxNum||17,
             rejArr=_rejArr||[],
             num=-1,
             flag=true;
         num = Math.floor(Math.random()*(maxNum-minNum+1)+minNum);
         if(rejArr.length>maxNum-minNum) return -1;
         for(var i=0,len=rejArr.length;i<len;i++){
    ...