Revisions
-
kerimdzhanov revised this gist
Feb 5, 2016 . No changes.There are no files selected for viewing
-
kerimdzhanov revised this gist
Dec 16, 2015 . 1 changed file with 15 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,21 @@ /** * Get a random floating point number between `min` and `max`. * * @param {number} min - min number * @param {number} max - max number * @return {float} a random floating point number */ function getRandom(min, max) { return Math.random() * (max - min) + min; } /** * Get a random integer between `min` and `max`. * * @param {number} min - min number * @param {number} max - max number * @return {int} a random integer */ function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } -
kerimdzhanov revised this gist
Jun 2, 2015 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ // MIT License // @return {float} a random number between min and max function getRandom(min, max) { return Math.random() * (max - min) + min; } // @return {integer} a random int between min and max function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } -
kerimdzhanov revised this gist
Nov 18, 2013 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +0,0 @@ -
kerimdzhanov created this gist
Nov 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ Note that as numbers in JavaScript are IEEE 754 floating point numbers with round-to-nearest-even behavior, these ranges, excluding the one for Math.random() itself, aren't exact, and depending on the bounds it's possible in extremely rare cases (on the order of 1 in 262) to calculate the usually-excluded upper bound. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // @return [float] a random number between min and max function getRandom(min, max) { return Math.random() * (max - min) + min; } // @return [integer] a random int between min and max function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); }