rng_uniform function typo

Moderation note: The first two posts of this thread were split from this thread.

I don’t know where to post this and this will probably be lost but here goes.

There is a piece of code that has been copy-pasted for years, containing a function “rng_uniform” to generate random numbers. I’ve seen it in this thread, on this forum in other threads, on the blender stack exchange, etc. it’s used in various contexts to get uniform random numbers for example out of the cell noise function.

The code has a typo in it. Every copy I’ve seen has the same typo. It uses the magic number 2137483647. The correct value is 2147483647, (note the third digit). This is Mersenne prime number M31 (2^31-1).

I don’t think it’s particularly critical for the type of randomness expected but I just wanted to get this written down somewhere.

@jobigoud nice catch! Just don’t know if it changes anything… Changing my scripts now! :slight_smile:

Cycles source code is in fact now using 2147483647, thought I remember taking that code from some script from Brecht… maybe was already adulterated at the copy time.

… and after a quick grep… my copy of Shane Ambler’s github is full of the same mistake!