Hi all,

The RND function incorporated in PB (as in most other languages) is based on the linear congruence algorithm and natively produces a cyclic sequence of 2^31 Long Integers (then reduced to floats in the interval 0-1).

The formula for successive random numbers is (similar to) the following:

X(n+1) = k*X(n) MOD m

where a "good choice" of the constants k and m is crucial for getting a decent "pseudorandomness".

In the "32 bits" (LONG integer) based generator, m is usually (2^31-1).

Now I would like to build my own generator producing a much longer cyclic sequence, based on QUAD integers.

Che choice for m would then be (2^63-1), but I need a "good" and tested value for k.

Does anybody have the right suggestion ?

P.S. Knuth gives the value for m = (2^64-1), but I need m = (2^63-1) so that I can use the signed QUAD datatype.

P.P.S.

Sorry, I realize that for using standard QUAD arithmetics m can never be (2^63-1). It must be such that m*k < (2^63-1).

The RND function incorporated in PB (as in most other languages) is based on the linear congruence algorithm and natively produces a cyclic sequence of 2^31 Long Integers (then reduced to floats in the interval 0-1).

The formula for successive random numbers is (similar to) the following:

X(n+1) = k*X(n) MOD m

where a "good choice" of the constants k and m is crucial for getting a decent "pseudorandomness".

In the "32 bits" (LONG integer) based generator, m is usually (2^31-1).

Now I would like to build my own generator producing a much longer cyclic sequence, based on QUAD integers.

Che choice for m would then be (2^63-1), but I need a "good" and tested value for k.

Does anybody have the right suggestion ?

P.S. Knuth gives the value for m = (2^64-1), but I need m = (2^63-1) so that I can use the signed QUAD datatype.

P.P.S.

Sorry, I realize that for using standard QUAD arithmetics m can never be (2^63-1). It must be such that m*k < (2^63-1).

## Comment