Jump to content

Talk:Pseudo-random numbers/Xorshift star

From Rosetta Code

Inappropriate masks?

Python does not have an unsigned 64 bit integer type or an unsigned 32 bit integer type. It has an integer type whose size varies to accept its operators, and where appropriate, leading zeroes are dropped.

Most of these bit-twizzling algorithms are originally written in languages like C that have these types. To duplicate the calculations, the Python example may use 32 bit and 64 bit mask values. anding a value with them will truncate that value to a maximum of 32/64 bits.

Fpr languages with these types, this would not be an idiomatic solution. Please use those types if they are a part of your language rather than follow the Python masking route, thanks. --Paddy3118 (talk) 10:58, 13 August 2020 (UTC)

Check for non-zero seed?

I notice that the pseudocode specifically mentions:

   u64 state       /* Must be seeded to non-zero initial value */

yet most of the entries not only allow a seed of 0, but in fact default to a seed of 0. If you're expecting good randomness with a seed of 0, you're gonna have a bad time. I hesitate to mark them all as wrong as that is just a comment in the pseudocode, not a specific task requirement, but I wonder if it should be? (The Raku entry specifically disallows zero (and negative numbers) as a seed value) --Thundergnat (talk) 18:57, 13 August 2020 (UTC)

I see your point. It is written as a comment, but the task states what seed values to use to give expected output, so I'd leave it myself. --Paddy3118 (talk) 11:05, 6 September 2020 (UTC)

XKCD

Missy elliot :-)
--Paddy3118 (talk) 08:20, 10 October 2020 (UTC)

Cookies help us deliver our services. By using our services, you agree to our use of cookies.