I’m curious if anyone has experience with random.fraction vs Math.random() on the server (no need to account for browser differences in your response) as I’m using Math.random() now for a dice game’s random dice rolls. Is there any benefit to using random.fraction instead?
You can probably answer that for yourself by reading the source for Random:
// We use cryptographically strong PRNGs (crypto.getRandomBytes() on the server,
// window.crypto.getRandomValues() in the browser) when available. If these
// PRNGs fail, we fall back to the Alea PRNG, which is not cryptographically
// strong, and we seed it with various sources such as the date, Math.random,
// and window size on the client. When using crypto.getRandomValues(), our
// primitive is hexString(), from which we construct fraction(). When using
// window.crypto.getRandomValues() or alea, the primitive is fraction and we use
// that to construct hex string.
if (Meteor.isServer)
var nodeCrypto = Npm.require('crypto');
// see http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
// for a full discussion and Alea implementation.
var Alea = function () {
function Mash() {
var n = 0xefc8249d;
var mash = function(data) {
data = data.toString();
This file has been truncated. show original
and comparing with: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
1 Like
0 inclusive! That’s friggin’ fantastic, lol.