Skip to content

Commit 1716fcd

Browse files
author
Ben D'Angelo
committed
tweaked random method
1 parent 3e4f12c commit 1716fcd

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/math/random.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
re.random() // 0 - 1
3-
re.random(10) // 0 - 9
4-
re.random(10, 30) // 10 - 30
2+
re.random() // 0 - 1 floats
3+
re.random(10) // 0 - 9 integer
4+
re.random(10, 30) // 10 - 30 integer
55
re.random([1, 10, 40]) // 1 or 10 or 40
66
77
*/
@@ -14,12 +14,8 @@ re.random = function(max, min){
1414
case 0:
1515
return r;
1616
case 1:
17-
return r * max;
17+
return r * max | 0;
1818
case 2:
19-
return r * (max - min + 1) + min;
19+
return r * (max - min + 1) + min | 0;
2020
}
21-
};
22-
23-
re.randomInt = function(){
24-
return re.random.apply(re.random, arguments) | 0;
2521
};

0 commit comments

Comments
 (0)