dimanche 25 juin 2017

c/c++ - random number between 0 and 1 without using rand() [duplicate]

This question already has an answer here:

I am trying to generate a (pseudo) random number between 0 and 1 without using any functions like rand() or srand(). I found some answers here but none fit my problem.

I was thinking about something like

  • declaring a variable and getting a pointer to that variable
  • add a number to the pointer to get another pointer to a unknown memory address (I know it is bad practise)
  • doing some modulo operations and some bit shifting on the new variable I would like it to be as distributed as possible

thanks!




Aucun commentaire:

Enregistrer un commentaire