jeudi 20 février 2020

Does Python have a function to mimic the sequence of C's rand()?

I am looking for a Python function that will mimic the behavior of rand() (and srand()) in c with the following requirements:

  1. I can provide the same epoch time into the Python equivalent of srand() to seed the function
  2. The equivalent of rand()%256 should result in the same char value as in c if both were provided the same seed.

So far, I have considered both the random library and numpy's random library. Instead of providing a random number from 0 to 32767 as C does though both yield a floating point number from 0 to 1 on their random functions. When attempting random.randint(0,32767), I yielded different results than when in my C function.

TL;DR Is there an existing function/libary in Python that follows the same random sequence as C?




Aucun commentaire:

Enregistrer un commentaire