Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random values not sequential #39

Closed
sjaeckel opened this issue Jun 5, 2019 · 1 comment
Closed

Random values not sequential #39

sjaeckel opened this issue Jun 5, 2019 · 1 comment

Comments

@sjaeckel
Copy link

sjaeckel commented Jun 5, 2019

I recently discovered that RandSlv(16) does not return the same as calling RandSlv(8) twice and I wanted to ask if that's intended? I couldn't find anything regarding this in the documentation, probably I missed it?

@JimLewis
Copy link
Member

JimLewis commented Jun 5, 2019

This is normal.

RandSlv(16) uses the current seed and randomize a 16 bit number. The base randomization is 32 bits, so this is done with a single randomization.

The first RandSlv(8) uses the current seed to randomize an 8 bit number. The second RandSlv(8) uses the seed updated by the first randomization to randomize an 8 bit number.

Hence, in your RandSlv(16) you changed the seed once. In your RandSlv(8) you updated the seed twice. Not only will these produce different results, but if you replaced the RandSlv(16) by two separate RandSlv(8) you change the state of the seed after the test completes - which in turn will impact what the entire test does.

OTOH, RandSlv(48) will do two randomizations to product a 48 bit number. However, this number need not be the same as two separate RandSlv(24). OTOH if the seed value was the same at the start of these operations, the final seed value after both of these have occurred will be the same.

At the end of the day, what pseudo random does guarantee, is that if you start with the same seed value and do the same sequence, you will get the same values - and hence, the same test.

@JimLewis JimLewis closed this as completed Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants