Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63c0e18
commit fa41e1a
Showing
1 changed file
with
5 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 characters
fa41e1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielWeigl No, a random number between 0 and 1 multiplied by 2 and floored will result in 0 or 1.
But yeah, I'd be concerned about using Math.random() for cryptographic purposes.
fa41e1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tlrobinson, I browse Reddit, and I find you. You're everywhere dude.
fa41e1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tlrobinson: "[...] Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range. [...]"
(from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random )
This means math.Random() will never return "1" -> so math.Random()*2 is strictly < 2. Therefor floor() will never return 2
fa41e1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielWeigl But JavaScript arrays are 0-indexed, so in a 2 element array there's no element at index 2...
fa41e1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tlrobinson, ah - you a right, was my err... thx