8000 Releases · thomcc/pcg-random · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Releases: thomcc/pcg-random

v2.0.0

02 Jan 09:08
v2.0.0
a50cea0
Compare
Choose a tag to compare

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(...) and new PcgRandom(...) are now lo, hi (little endian) rather than hi, lo (big endian).

    While this is technically breaking, most usage will not be impacted.

  • new PcgRandom(...) and PcgRandom.prototype.setState(...) now can take the state array directly, which is equivalent to setState immediately after construction.

  • If BigInts are supported on the JS engine (which is not required), the seed/increment can be passed to new PcgRandom(...) and setSeed as BigInts.

  • 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 and new PcgRandom(...)) are now in little endian order (e.g. low, high, rather than high, 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.

0