Skip to content

Instantly share code, notes, and snippets.

@kisssko
Created February 3, 2022 10:09
Show Gist options
  • Save kisssko/f183a5bac1b0d5389b49e05a40ea5bbb to your computer and use it in GitHub Desktop.
Save kisssko/f183a5bac1b0d5389b49e05a40ea5bbb to your computer and use it in GitHub Desktop.
tiny randomizer
#include <stdint.h>
#include <stdlib.h>
uint32_t tiny_rand(void)
{
uint32_t t = _seed;
t ^= t >> 10;
t ^= t << 9;
t ^= t >> 25;
_seed = t;
return t & RAND_MAX;
}
void tiny_srand(uint32_t seed)
{
_seed = seed | 0x80000000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment