Created
February 3, 2022 10:09
-
-
Save kisssko/f183a5bac1b0d5389b49e05a40ea5bbb to your computer and use it in GitHub Desktop.
tiny randomizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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