[erlang-questions] On OTP rand module difference between OTP 19 and OTP 20

Raimo Niskanen raimo+erlang-questions@REDACTED
Fri Sep 1 10:49:58 CEST 2017


On Fri, Sep 01, 2017 at 02:57:49PM +1200, Richard A. O'Keefe wrote:
:
> 
> I could personally live with a warning in the documentation that says
> that the random number generator could return 0.0, and here's a little
> loop you might use to avoid that, and another suggestion in the code
> about how to get the result Michael Truog wants.
> 
> I just want it to be obvious that it's dangerous to assume that the
> result will not be 0.

That can surely merit a warning, even though the interval is documented.

> 
> By the way, given that a common way to make random floats is to
> generate a bitvector, consider
> (0 to: 15) collect: [:each | ((each / 15) * 256) truncated].
> You will notice that the spacing between the values is *almost*
> uniform, but not at the end.

That sounds interesting but I do not understand.  Is that Elixir code?

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list