Phasor 3.3.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
random.cpp
Go to the documentation of this file.
1#include "random.hpp"
2#include <phsint.hpp>
3
4// my tiny xorshift+ implementation
5// (C) Daniel McGuire -- MIT License
6
7static Phasor::u64 s[2];
8
10{
11 s[0] = s0;
12 s[1] = s1;
13}
14
16{
17 Phasor::u64 s1 = s[0];
18 Phasor::u64 s0 = s[1];
19
20 s[0] = s0;
21 s1 ^= s1 << 23;
22 s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5);
23
24 return s[1] + s0;
25}
26
28{
29 return (PHASORstd_rand_next() >> 11) * (1.0 / (UINT64_C(1) << 53));
30}
31
Phasor::u64 PHASORstd_rand_next()
Definition random.cpp:15
Phasor::f64 PHASORstd_rand_next_double()
Definition random.cpp:27
static Phasor::u64 s[2]
Definition random.cpp:7
void PHASORstd_rand_seed(Phasor::u64 s0, Phasor::u64 s1)
Definition random.cpp:9
Phasor::i64 PHASORstd_rand_next_range(Phasor::i64 min, Phasor::i64 max)
Definition random.cpp:32
int64_t i64
Definition phsint.hpp:16
double f64
Definition phsint.hpp:7
uint64_t u64
Definition phsint.hpp:12