最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - What algorithm does Math.random use? - Stack Overflow

matteradmin10PV0评论

Since I've been studying Computer Science, whenever random numbers e up, it's always Mersenne Twister. There's never even a question, no alternative. Just, use Mersenne Twister.

So what does JavaScript's Math.random use? It seems like it ought to use Mersenne Twister, since it's apparently without peer, but I can't find any reference to whether it does or not.

Does anyone know what it relies on, and/or why it isn't MT, if that's the case?

Since I've been studying Computer Science, whenever random numbers e up, it's always Mersenne Twister. There's never even a question, no alternative. Just, use Mersenne Twister.

So what does JavaScript's Math.random use? It seems like it ought to use Mersenne Twister, since it's apparently without peer, but I can't find any reference to whether it does or not.

Does anyone know what it relies on, and/or why it isn't MT, if that's the case?

Share Improve this question asked Apr 28, 2012 at 7:17 temporary_user_nametemporary_user_name 37.2k48 gold badges161 silver badges243 bronze badges 1
  • Quantum puting offers algorithms that can generate more "natural" random numbers. [Theoretically] – KBN Commented Apr 28, 2012 at 7:24
Add a ment  | 

1 Answer 1

Reset to default 7

It's likely implementation specific. The ECMAScript specification does not force any algorithm, so a Linux JavaScript implementation might very well use /dev/urandom.

Post a comment

comment list (0)

  1. No comments so far