diff options
| author | nasr <nsrddyn@gmail.com> | 2026-10-05 22:02:56 +0200 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2026-10-05 22:02:56 +0200 |
| commit | f6d3090f7fa76eb8e0dbe060b8490cb49c001c39 (patch) | |
| tree | 433c773997e51f22738acb8b04c4fd2fc6b1bdc9 /source/base/base_rand.cpp | |
init: base
Diffstat (limited to 'source/base/base_rand.cpp')
| -rw-r--r-- | source/base/base_rand.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/base/base_rand.cpp b/source/base/base_rand.cpp new file mode 100644 index 0000000..cf8d63a --- /dev/null +++ b/source/base/base_rand.cpp | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #define RAND_CONSTANT 6364136223846793005 | ||
| 2 | internal u64 rand_u64(u64 constant); | ||
| 3 | |||
| 4 | internal u64 rand_u64(u64 constant) | ||
| 5 | { | ||
| 6 | time_t current_time = time(0); | ||
| 7 | constant = current_time ^ constant; | ||
| 8 | |||
| 9 | constant += 0x9e3779b97f4a7c15; | ||
| 10 | |||
| 11 | u64 z = constant; | ||
| 12 | z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9; | ||
| 13 | z = (z ^ (z >> 27)) * 0x94d049bb133111eb; | ||
| 14 | z = z ^ (z >> 31); | ||
| 15 | |||
| 16 | return z; | ||
| 17 | } | ||
| 18 | |||
| 19 | // TODO: bah i don't know if this is good \ No newline at end of file | ||
