3 ms·
I'm curious in what field (of programming) are these examples. The reason is because I cannot recall a single rng I've looked at that uses floating point. Must
by 112233 4y ago
I'm curious in what field (of programming) are these examples. The reason is because I cannot recall a single rng I've looked at that uses floating point. Must be a different use case
- hinkley 4y agoLanguages that use this pattern, in decreasing order of familiarity and increasing levels of Googling: Java, Javascript, Python, Ruby, Perl languages where it's optional: C#, Elixir, Go That's about when I got tired of Googling.
- silon42 4y agofor Java first hit in google 'java random' has counterexamples
- hinkley 4y agohttps://docs.oracle.com/javase/7/docs/api/java/lang/Math.html https://docs.oracle.com/javase/7/docs/api/java/lang/Math.htm... Random also exists, with a bunch of options including CSPRNG. But if you’re just simulating a die roll, Math.random is sufficient unless you’re writing gambling software.
- edflsafoiewq 4y agoJava, Python, and Ruby all have explicit functions to generate an integer in a range. Java: Random.nextInt(b) Python: random.randrange(b) Ruby: rand(b)