dimanche 27 août 2017

What is the fastest way to produce random floats in {-1.0, +1.0} in C++?

Currently, my solution is to compute (float) (2 * (rand() % 2)) - 1. Are there more efficient ways of doing this, for example by producing random bits and placing them at the respective position for the sign of a 1.0 float constant using bit-twiddling?




Aucun commentaire:

Enregistrer un commentaire