Changes
-
Fixes a bug where we would return a different integer sequence than the reference implementation (#2).
-
Improved documentation (arguably).
-
(BREAKING): No more use of big endian.
- State arrays are now as little endian rather than big endian.
- 64 bit parameters provided as a pair of 32 bit integers to
rng.setSeed(...)
andnew PcgRandom(...)
are nowlo, hi
(little endian) rather thanhi, lo
(big endian).
While this is technically breaking, most usage will not be impacted.
-
new PcgRandom(...)
andPcgRandom.prototype.setState(...)
now can take the state array directly, which is equivalent tosetState
immediately after construction. -
If
BigInt
s are supported on the JS engine (which is not required), the seed/increment can be passed tonew PcgRandom(...)
andsetSeed
asBigInt
s. -
New function:
PcgRandom.prototype.next32()
which directly calls the RNG and returns the next 32 bit integer.
Compatibility
This is mostly compatible (including supporting all the same JS engines), but a major version bump was done because:
-
Hardcoded seed values will not return the same sequence of integers.
-
State arrays and function arguments (for
setSeed
andnew PcgRandom(...)
) are now in little endian order (e.g.low, high
, rather thanhigh, low
for 64 bit parameters provided as a pair of 32 bit integers).This is technically not compatible, although it's unlikely your code will need to change unless you're providing hardcoded integer values, or loading seeds serialized to json.