How do you generate a random double uniformly distributed between 0 and 1 from C++?

Viewed 121305

How do you generate a random double uniformly distributed between 0 and 1 from C++?

Of course I can think of some answers, but I'd like to know what the standard practice is, to have:

  • Good standards compliance
  • Good randomness
  • Good speed

(speed is more important than randomness for my application).

Thanks a lot!

PS: In case that matters, my target platforms are Linux and Windows.

13 Answers
Related