Skip to content

Instantly share code, notes, and snippets.

@andrewharmellaw
Created December 23, 2015 07:28
Show Gist options
  • Save andrewharmellaw/4a42eb6ac1f2db9d502b to your computer and use it in GitHub Desktop.
Save andrewharmellaw/4a42eb6ac1f2db9d502b to your computer and use it in GitHub Desktop.
The function to alias - nextInt
def nextInt: (Int, RNG) = {
val newSeed = (seed * 0x5DEECE66DL + 0xBL) & 0xFFFFFFFFFFFFL
val nextRNG = SimpleRNG(newSeed)
val n = (newSeed >>> 16).toInt
(n, nextRNG)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment