3 ms·
Most JavaScript codebases that I have read over use the division based method, it’s rare to find one that uses a random floating point multiplied by the limit (
by EthicalSimilar 4y ago
Most JavaScript codebases that I have read over use the division based method, it’s rare to find one that uses a random floating point multiplied by the limit (outside of Math.random(), I’m talking about crypto.getRandomBytes() implementations).
I think this is likely due to the nature of JavaScript’s whacky integer and float implementations.