What is a good, fast PRNG (not cryptographically secure)

I am looking for a quick PRNG to quickly create (semi) unique identifiers for objects. Uniqueness is rather a management problem, and duplication of identifiers is a problem only in extremely rare circumstances.

It should be as fast as possible, since the performance is critical and not consistent (if the identifiers are consistent, this makes the error on the control side more likely). In addition, I would like to avoid lower numbers, but this can be easily mitigated by simply repeating until a sufficiently large number is found.

Edit I also have to add that I need the identifiers to be 32 bits, so the GUIDs do not work and must be platform independent (they are currently implemented on a PC, but it also needs to work with Nintendo DS, PSP, PS3, Wii, Xbox and other platforms). In addition, it can be called thousands of times per second, so the generation of random numbers based on input is impossible.

thanks

+1
source share
9 answers

This might work:

The sum of the current time since epoch, the stream identifier, and the serial number.

0
source

GUIDs ? Many environments support them.

+3
source

, X[i] = (X[i-1] + a) mod b? a b , b. b = 2 ^ 32 , a > 2. , .

: X[i] = offset + (X[i-1] - offset + a) mod b?

+1

, , Linux-, /dev/urandom, . , . , (/).

0

PRNG - , . , , , /dev/random.

" ", , ; . . :

random() % 1000000

0 999,999.

0
0

PRNG (A(x) = A(x-1)|m). fooobar.com/questions/17351/... . 64- (64- long long C), , 2 ^ 30 M = 2 ^ 31- 1. , , A .

0

this. .

2 .

0

, , , , , 10k .

, , prngs . 25653 7567832 . .

prng , , . , , prng. , .

0
source

Source: https://habr.com/ru/post/1715659/


All Articles