Skip to content

Instantly share code, notes, and snippets.

@naganowl
Last active August 29, 2015 14:00
Show Gist options
  • Save naganowl/aef87333e2a7dbfee42d to your computer and use it in GitHub Desktop.
Save naganowl/aef87333e2a7dbfee42d to your computer and use it in GitHub Desktop.
Simple line to generate random integers
  • Taken from here.
  • Bitwise OR with 0 floors the number it's paired with.
    • Performance is similar to Math.floor().
  • The post highlights it's higher performance to pre-generate random numbers and then loop through them.
Math.random()*101|0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment