3 ms·
The shift-xor "random" number generator described actually has an interesting property. The algorithm looks like this: 1. If the value is 0, output the magic n
by russellsprouts 10y ago
The shift-xor "random" number generator described actually has an interesting property. The algorithm looks like this:
1. If the value is 0, output the magic number.
2. If the value has only its high bit set, output 0.
3. Otherwise, shift the value to the left
4. if there was an overflow (the high bit was 1 before the shift), xor the value by a magic constant.
For certain values of the magic constant, this has the property of generating every integer in the range exactly once.
- mzs 10y agoAnd with 077213 and 012345 octal that is what happens. That's why the distribution was so uniform when Ken checked.
- userbinator 10y agohttps://en.wikipedia.org/wiki/Linear-feedback_shift_register#Uses_in_circuit_testing https://en.wikipedia.org/wiki/Linear-feedback_shift_register... I suspect it was deliberately chosen to do this for the purposes of testing the disk; the sequence is random-looking so it exercises all the bits, but is also deterministic so that written data can be verified by reading it back and comparing without having to store a copy of all the written data somewhere else.